diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 898be56..0000000 --- a/Gemfile +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -gem 'foreman' -gem 'sinatra' -gem 'puma' -gem "sinatra-activerecord" -gem "sqlite3" -gem "rake" - -gem "rackup", "~> 2.1" - -gem "sinatra-contrib", "~> 4.0" - -gem "timecop", "~> 0.9.8" diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 6ffd52d..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,110 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activemodel (8.0.1) - activesupport (= 8.0.1) - activerecord (8.0.1) - activemodel (= 8.0.1) - activesupport (= 8.0.1) - timeout (>= 0.4.0) - activesupport (8.0.1) - base64 - benchmark (>= 0.3) - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - base64 (0.2.0) - benchmark (0.4.0) - bigdecimal (3.1.9) - concurrent-ruby (1.3.5) - connection_pool (2.5.0) - drb (2.2.1) - foreman (0.88.1) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - logger (1.6.6) - minitest (5.25.4) - multi_json (1.15.0) - mustermann (3.0.3) - ruby2_keywords (~> 0.0.1) - nio4r (2.7.4) - puma (6.6.0) - nio4r (~> 2.0) - rack (3.1.11) - rack-protection (4.1.1) - base64 (>= 0.1.0) - logger (>= 1.6.0) - rack (>= 3.0.0, < 4) - rack-session (2.1.0) - base64 (>= 0.1.0) - rack (>= 3.0.0) - rackup (2.2.1) - rack (>= 3) - rake (13.2.1) - ruby2_keywords (0.0.5) - securerandom (0.4.1) - sinatra (4.1.1) - logger (>= 1.6.0) - mustermann (~> 3.0) - rack (>= 3.0.0, < 4) - rack-protection (= 4.1.1) - rack-session (>= 2.0.0, < 3) - tilt (~> 2.0) - sinatra-activerecord (2.0.28) - activerecord (>= 4.1) - sinatra (>= 1.0) - sinatra-contrib (4.1.1) - multi_json (>= 0.0.2) - mustermann (~> 3.0) - rack-protection (= 4.1.1) - sinatra (= 4.1.1) - tilt (~> 2.0) - sqlite3 (2.6.0-aarch64-linux-gnu) - sqlite3 (2.6.0-aarch64-linux-musl) - sqlite3 (2.6.0-arm-linux-gnu) - sqlite3 (2.6.0-arm-linux-musl) - sqlite3 (2.6.0-arm64-darwin) - sqlite3 (2.6.0-x86-linux-gnu) - sqlite3 (2.6.0-x86-linux-musl) - sqlite3 (2.6.0-x86_64-darwin) - sqlite3 (2.6.0-x86_64-linux-gnu) - sqlite3 (2.6.0-x86_64-linux-musl) - tilt (2.6.0) - timecop (0.9.10) - timeout (0.4.3) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.0.3) - -PLATFORMS - aarch64-linux-gnu - aarch64-linux-musl - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86-linux-gnu - x86-linux-musl - x86_64-darwin - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - foreman - puma - rackup (~> 2.1) - rake - sinatra - sinatra-activerecord - sinatra-contrib (~> 4.0) - sqlite3 - timecop (~> 0.9.8) - -BUNDLED WITH - 2.5.19 diff --git a/Procfile b/Procfile deleted file mode 100644 index f8fcf07..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: ruby mood_app.rb diff --git a/Rakefile b/Rakefile deleted file mode 100644 index e4864b9..0000000 --- a/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -# Rakefile -require "sinatra/activerecord/rake" - -namespace :db do - task :load_config do - require "./mood_app" - end -end diff --git a/db/migrate/20240211182231_create_moods.rb b/db/migrate/20240211182231_create_moods.rb deleted file mode 100644 index bcd196d..0000000 --- a/db/migrate/20240211182231_create_moods.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateMoods < ActiveRecord::Migration[7.1] - def change - create_table :moods do |t| - t.string :mode, null: false - t.datetime :recorded_at, precision: nil, null: false - end - end -end diff --git a/db/migrate/20241101211840_create_events.rb b/db/migrate/20241101211840_create_events.rb deleted file mode 100644 index 4780f1e..0000000 --- a/db/migrate/20241101211840_create_events.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateEvents < ActiveRecord::Migration[7.2] - def change - create_table :events do |t| - t.string :title - t.text :description - t.datetime :taken_place_on, precision: nil, null: false - end - end -end diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index 9fb6faf..0000000 --- a/db/schema.rb +++ /dev/null @@ -1,24 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.2].define(version: 2024_11_01_211840) do - create_table "events", force: :cascade do |t| - t.string "title" - t.text "description" - t.datetime "taken_place_on", precision: nil, null: false - end - - create_table "moods", force: :cascade do |t| - t.string "mode", null: false - t.datetime "recorded_at", precision: nil, null: false - end -end diff --git a/draft b/draft deleted file mode 100644 index d75fdbe..0000000 --- a/draft +++ /dev/null @@ -1,15 +0,0 @@ -x prendre billet de train -x répondre à Laurent -x noter agenda yaf et coopaname - -- faire moodtracker mobile - -- faire vaisselle -- vider poubelles -- demander à mathieu quel jour -- laver drap -- appeler athie - -- répondre à delphine -- redige mail julie sauzin - diff --git a/event.rb b/event.rb deleted file mode 100644 index fdf513b..0000000 --- a/event.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Event < ActiveRecord::Base - default_scope { order(:taken_place_on) } - validates_presence_of :title - validates_presence_of :taken_place_on - -end - diff --git a/mood.rb b/mood.rb deleted file mode 100644 index 0932b18..0000000 --- a/mood.rb +++ /dev/null @@ -1,28 +0,0 @@ -class Mood < ActiveRecord::Base - default_scope { order(:recorded_at) } - validates_presence_of :mode - validates_presence_of :recorded_at - - def self.log - return if Mood.count < 1 - - first_mood = Mood.first.recorded_at.to_date - first_monday = first_mood - (first_mood.wday - 1) - - current_date = first_monday - current_mode = nil - log_mood = [] - Mood.all.each do |mood| - while current_date < mood.recorded_at.to_date do - log_mood << [ current_date.to_s, current_mode ] - current_date += 1 - end - current_mode = mood.mode - end - while current_date <= Date.today do - log_mood << [ current_date.to_s, current_mode ] - current_date += 1 - end - log_mood.each_slice(7).to_a.last(52) - end -end diff --git a/mood_app.rb b/mood_app.rb deleted file mode 100644 index 9ab7612..0000000 --- a/mood_app.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'sinatra/base' -require 'sinatra/namespace' -require 'sinatra/activerecord' -require './mood' -require './event' - -class MoodApp < Sinatra::Base - register Sinatra::ActiveRecordExtension - register Sinatra::Namespace - set :database, { adapter: 'sqlite3', database: "mood-#{ENV['RACK_ENV']}.sqlite3" } - set :bind, '::1' - - get '/' do - @mode = Mood.last&.mode || 'croisiere' - @mood_log = Mood.log || [] - erb :index - end - - namespace '/api/v1' do - before do - content_type 'application/json' - end - - post '/moods' do - json = request.body.read - puts json - data = JSON.parse json - Mood.create(mode: data['mode'], recorded_at: Time.now) - end - end - - run! if app_file == $0 -end diff --git a/mood_app_spec.rb b/mood_app_spec.rb deleted file mode 100644 index af0b8a1..0000000 --- a/mood_app_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -ENV['APP_ENV'] = 'test' - -require './mood_app' -require 'rspec' -require 'rack/test' - -describe 'MoodApp' do - include Rack::Test::Methods - - it 'says hello' do - get '/' - expect(last_response).to be_ok - end - - def app - MoodApp - end -end diff --git a/mood_spec.rb b/mood_spec.rb deleted file mode 100644 index 7c8c87a..0000000 --- a/mood_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -ENV['APP_ENV'] = 'test' - -require './mood_app' -require 'rspec' -require 'timecop' - -describe 'Mood' do - before do - Mood.destroy_all - Timecop.freeze(Time.local(2024,2,10,9)) - end - - after do - Timecop.return - end - - it 'returns log' do - Mood.create(recorded_at: '2024-02-03', mode: 'creatif') - Mood.create(recorded_at: '2024-02-09', mode: 'en-charge') - - expect(Mood.log).to eq [ - [ - {'2024-01-29' => nil}, - {'2024-01-30' => nil}, - {'2024-01-31' => nil}, - {'2024-02-01' => nil}, - {'2024-02-02' => nil}, - {'2024-02-03' => 'creatif'}, - {'2024-02-04' => 'creatif'} - ], - [ - {'2024-02-05' => 'creatif'}, - {'2024-02-06' => 'creatif'}, - {'2024-02-07' => 'creatif'}, - {'2024-02-08' => 'creatif'}, - {'2024-02-09' => 'en-charge'}, - {'2024-02-10' => 'en-charge'} - ] - ] - end -end - diff --git a/public/creatif.jpg b/public/creatif.jpg deleted file mode 100644 index 756b311..0000000 Binary files a/public/creatif.jpg and /dev/null differ diff --git a/public/creatif.png b/public/creatif.png deleted file mode 100644 index 37c656f..0000000 Binary files a/public/creatif.png and /dev/null differ diff --git a/public/croisiere.jpg b/public/croisiere.jpg deleted file mode 100644 index 4afdfc6..0000000 Binary files a/public/croisiere.jpg and /dev/null differ diff --git a/public/croisiere.png b/public/croisiere.png deleted file mode 100644 index 3d7344e..0000000 Binary files a/public/croisiere.png and /dev/null differ diff --git a/public/en-charge.jpg b/public/en-charge.jpg deleted file mode 100644 index a8e21a6..0000000 Binary files a/public/en-charge.jpg and /dev/null differ diff --git a/public/en-charge.png b/public/en-charge.png deleted file mode 100644 index 52c6a4a..0000000 Binary files a/public/en-charge.png and /dev/null differ diff --git a/public/frigo-vide.jpg b/public/frigo-vide.jpg deleted file mode 100644 index 61f748f..0000000 Binary files a/public/frigo-vide.jpg and /dev/null differ diff --git a/public/frigo-vide.png b/public/frigo-vide.png deleted file mode 100644 index 4e265b2..0000000 Binary files a/public/frigo-vide.png and /dev/null differ diff --git a/public/main.css b/public/main.css deleted file mode 100644 index 35757cc..0000000 --- a/public/main.css +++ /dev/null @@ -1,187 +0,0 @@ -body { - margin: 0px; - font-family: "Sour Gummy", sans-serif; - font-weight: 350; - font-style: normal; -} - -.mode { - grid-area: mode; - height: 50vh; -} - -.tracker { - grid-area: tracker; -} - -.title { - grid-area: title; - margin: 30px; - font-size: 2rem; -} - -.legend .bar-creatif { - background: red; - width: 10px; - height: 10px; - margin-left: 15px; -} -.legend .bar-frigo { - background: gray; - width: 10px; - height: 10px; - margin-left: 15px; -} -.legend .bar-croisiere { - background: green; - width: 10px; - height: 10px; - margin-left: 15px; -} -.legend .bar-en-charge { - background: orange; - width: 10px; - height: 10px; - margin-left: 15px; -} -.legend .bar-explain { - padding-left: 3px; -} - -.legend-mood { - display: flex; - align-items: center; -} - -main { - display: block; - grid-template-rows: 1fr 1fr; - grid-template-areas: - "mode" - "tracker"; - align-items: center; - justify-content: center; -} -.mode img { - height: 100%; - width:100%; - object-fit: contain; -} -.tracker { - grid-area: tracker; -} -.title h1 { - font-weight: 350; -} - -@media (min-width: 1000px) { - main { - display: grid; - grid-template-columns: 1fr 1fr; - grid-template-rows: 1fr; - grid-template-areas: "mode tracker"; - align-items: center; - justify-content: center; - } - - .mode { - height: 100vh; - grid-area: mode; - } - .tracker { - grid-area: tracker; - display: grid; - grid-template-columns: 1fr 1fr; - grid-template-rows: 2fr 1fr 6fr 1fr; - grid-template-areas: - "title title" - "info-day info-day" - "moods moods" - ". legend"; - background-color: lightgoldenrodyellow; - align-items: center; - justify-content: center; - height: 100vh; - width: 100%; - gap: 45px; - } - - .title { - grid-area: title; - margin: 30px; - } - - .info-day { - grid-area: info-day; - margin: 30px; - font-size: 1.8rem; - } - - .info { - grid-area: info; - } - - .mode img { - height: 100%; - width:100%; - object-fit: contain; - } - .title h1 { - font-weight: 350; - } -} -.moods { - grid-area: moods; - margin: 30px; - max-height: 100%; - display: flex; - flex-direction: column; - overflow: hidden; -} - -.legend { - grid-area: legend; - margin: 4px; - font-size: 0.8rem; - display: flex; - flex-direction: row; - align-items: flex-end; - justify-content: flex-end; - margin: 30px; -} -.log { - align-self: flex-end; - display: flex; - flex-wrap: wrap; - align-items: flex-start; - overflow: hidden; -} -.moods .log .week { - display: flex; - flex-direction: column; - justify-items: start; - flex-wrap: wrap; - margin-bottom: 20px; -} -.moods .log .day { - border: 1px; - margin: 4px; - min-width: 15px; - min-height: 15px; -} -.creatif { - background-color: red; -} -.en-charge { - background-color: orange; -} -.frigo-vide { - background-color: grey; -} -.croisiere { - background-color: green; -} - -.info { - margin: 30px; -} diff --git a/public/triste.jpg b/public/triste.jpg deleted file mode 100644 index 61f748f..0000000 Binary files a/public/triste.jpg and /dev/null differ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index db17885..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,100 +0,0 @@ -ENV["RACK_ENV"] = 'test' - -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end -end diff --git a/views/index.erb b/views/index.erb deleted file mode 100644 index c903c97..0000000 --- a/views/index.erb +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - -
-
- -
-
-
-

Comment il va le Robi ?

-
-
Aujourd'hui
-
-
- <% @mood_log.each do |week| %> -
- <% week.each do |d| %> - <% if d[1] %> -
- <% else %> -
- <% end %> - <% end %> -
- <% end %> -
-
-
-
-
-
Triste
-
-
-
-
En charge
-
-
-
-
Croisiere
-
-
-
-
Créatif
-
-
-
-