diff --git a/Gemfile b/Gemfile index b625ba3..34528d9 100644 --- a/Gemfile +++ b/Gemfile @@ -73,3 +73,8 @@ end gem 'bootstrap', '~> 4.0.0.alpha6' gem 'jquery-rails' gem 'font-awesome-sass', '~> 4.7.0' + + +gem 'momentjs-rails' +gem 'bootstrap3-datetimepicker-rails' +gem 'chronic' diff --git a/Gemfile.lock b/Gemfile.lock index a4b753b..57433fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/firstdraft/grade_runner.git - revision: 881cce30367bc9a5f15a3e4ac4cb48599dbecec2 + revision: 83db5d2b90086055aa3204afe38a18394aecea16 specs: grade_runner (0.0.1) @@ -62,7 +62,7 @@ GEM activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) arel (8.0.0) - autoprefixer-rails (7.1.1.3) + autoprefixer-rails (7.1.2.2) execjs awesome_print (1.8.0) better_errors (2.1.1) @@ -75,6 +75,8 @@ GEM bootstrap (4.0.0.alpha6) autoprefixer-rails (>= 6.0.3) sass (>= 3.4.19) + bootstrap3-datetimepicker-rails (4.17.47) + momentjs-rails (>= 2.8.1) builder (3.2.3) byebug (9.0.6) callsite (0.0.11) @@ -85,6 +87,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + chronic (0.10.2) coderay (1.1.1) concurrent-ruby (1.0.5) crack (0.4.3) @@ -110,7 +113,7 @@ GEM globalid (0.4.0) activesupport (>= 4.2.0) hashdiff (0.3.4) - i18n (0.8.4) + i18n (0.8.6) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) @@ -140,6 +143,8 @@ GEM mime-types-data (3.2016.0521) mini_portile2 (2.2.0) minitest (5.10.2) + momentjs-rails (2.17.1) + railties (>= 3.1) multi_json (1.12.1) nio4r (2.1.0) nokogiri (1.8.0) @@ -208,7 +213,11 @@ GEM rspec-support (3.6.0) ruby_dep (1.5.0) safe_yaml (1.0.4) - sass (3.4.24) + sass (3.5.0) + sass-listen (~> 3.0.7) + sass-listen (3.0.7) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) @@ -262,8 +271,10 @@ DEPENDENCIES better_errors binding_of_caller bootstrap (~> 4.0.0.alpha6) + bootstrap3-datetimepicker-rails byebug capybara + chronic dotenv-rails factory_girl_rails firstdraft_generators @@ -274,6 +285,7 @@ DEPENDENCIES letter_opener listen (>= 3.0.5, < 3.2) meta_request + momentjs-rails pry-rails puma (~> 3.7) rails (~> 5.1.2) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 739c2fe..2791911 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,6 +11,15 @@ // about supported directives. // //= require rails-ujs +//= require jquery //= require bootstrap //= require turbolinks //= require_tree . + + +//= require moment +//= require bootstrap-datetimepicker + +$(function () { + $('.datetimepicker').datetimepicker(); +}); \ No newline at end of file diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..0794b66 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,13 +11,20 @@ def word_count # ================================================================================ - @word_count = "Replace this string with your answer." - @character_count_with_spaces = "Replace this string with your answer." + @word_count = @text.split(" ").length - @character_count_without_spaces = "Replace this string with your answer." + @character_count_with_spaces = @text.length - @occurrences = "Replace this string with your answer." + @character_count_without_spaces = @text.length-@text.count(" ") + + punctuation = @text.chomp(".") + + downcased_words = punctuation.downcase.split(" ") + + downcased_special = @special_word.downcase + + @occurrences = downcased_words.count(downcased_special) # ================================================================================ # Your code goes above. @@ -38,7 +45,10 @@ def loan_payment # The principal value the user input is in the decimal @principal. # ================================================================================ - @monthly_payment = "Replace this string with your answer." + monthly_interest = (@apr/12)/100 + number_of_monthly_payments = @years*-12 + + @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) # ================================================================================ # Your code goes above. @@ -60,12 +70,12 @@ def time_between # number of seconds as a result. # ================================================================================ - @seconds = "Replace this string with your answer." - @minutes = "Replace this string with your answer." - @hours = "Replace this string with your answer." - @days = "Replace this string with your answer." - @weeks = "Replace this string with your answer." - @years = "Replace this string with your answer." + @seconds = @ending-@starting + @minutes = @seconds/60 + @hours = @minutes/60 + @days = @hours/24 + @weeks = @days/7 + @years = @weeks/52 # ================================================================================ # Your code goes above. @@ -76,33 +86,40 @@ def time_between def descriptive_statistics @numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + + # ================================================================================ # Your code goes below. # The numbers the user input are in the array @numbers. # ================================================================================ - @sorted_numbers = "Replace this string with your answer." + @sorted_numbers = @numbers.sort + + @count = @numbers.count - @count = "Replace this string with your answer." + @minimum = @numbers.min - @minimum = "Replace this string with your answer." + @maximum = @numbers.max - @maximum = "Replace this string with your answer." + @range = @maximum-@minimum - @range = "Replace this string with your answer." + @median = @sorted_numbers[((@count/2)+(1/2))] - @median = "Replace this string with your answer." + @sum = @numbers.sum - @sum = "Replace this string with your answer." + @mean = @sum/@count - @mean = "Replace this string with your answer." + @demeaned=@numbers.map { |i| i - @mean} + @squared = @demeaned.map { |i| i**2} + @variance = @squared.sum / @count - @variance = "Replace this string with your answer." + @variance = @squared.sum / @count - @standard_deviation = "Replace this string with your answer." + @standard_deviation = Math.sqrt(@variance) - @mode = "Replace this string with your answer." + @mode_count = @numbers.map { |i| @numbers.count(i)} + @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] # ================================================================================ # Your code goes above. diff --git a/circle.yml b/circle.yml index c32e24c..b895dc3 100644 --- a/circle.yml +++ b/circle.yml @@ -4,9 +4,7 @@ machine: ruby: version: 2.3.1 -database: - override: - - bin/setup + test: override: - COVERAGE=true bin/rails grade_runner:runner