som-timer 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/som_timer.rb +28 -21
- data/lib/som_timer/service.rb +62 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26378a82ead55dae01edf0e85ed33d5804efbfb055592a187ddd5630bde905d4
|
4
|
+
data.tar.gz: e9cb01b178e6c88eeaac2bc6b5f76cc48f1bf1daf8d4de980572e4d99921afb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea0d3fe95f5e4e55d87402b8893b7a529ad8e11615c0419e6cd5af3332fb13d6dbd8c15c28a6d96612c805826b8b74499292bac9b1d613eca5c5dcbfd0ed7e0
|
7
|
+
data.tar.gz: 480392abaff55b01197e9c39035b3500320826a851083f170e433f9559f5b16463baeff540c3ead75d82e3f406089aad71bc9077ecd26980007adcb51e280bdc
|
data/lib/som_timer.rb
CHANGED
@@ -3,34 +3,41 @@ require "pry"
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
class SomTimer
|
6
|
-
def self.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
puts hash
|
6
|
+
def self.hello_world
|
7
|
+
puts "Hello World! This is SomTimer, a timer that cares.
|
8
|
+
\nBased on the pomodoro technique™️, this application provides users with curated wellness content during break intervals.
|
9
|
+
\nBuild in rest, so you can focus best."
|
11
10
|
end
|
12
11
|
|
13
|
-
def self.update_timer(work_interval, rest_interval, sound)
|
14
|
-
|
15
|
-
|
16
|
-
req.url "https://som-timer-be.herokuapp.com/api/timers/1"
|
17
|
-
req.headers['Content-Type'] = 'application/json'
|
18
|
-
req.body = { "work_interval": "#{work_interval}", "rest_interval": "#{rest_interval}", "sound": "#{sound}" }.to_json
|
19
|
-
end
|
20
|
-
hash = JSON.parse(response.body, symbolize_names: true)
|
21
|
-
puts hash
|
12
|
+
def self.update_timer(work_interval, rest_interval, sound, path = "timers/1")
|
13
|
+
service = Service.new(path)
|
14
|
+
service.update_timer(work_interval, rest_interval, sound)
|
22
15
|
end
|
23
16
|
|
24
|
-
def self.one_timer
|
25
|
-
|
17
|
+
def self.one_timer(path = "timers/1")
|
18
|
+
service = Service.new(path)
|
19
|
+
service.timer
|
26
20
|
end
|
27
21
|
|
28
|
-
def self.rand_exercise(duration, category)
|
29
|
-
|
30
|
-
|
22
|
+
def self.rand_exercise(duration, category, path = "rand_exercise")
|
23
|
+
service = Service.new(path)
|
24
|
+
service.rand_exercise(duration, category)
|
31
25
|
end
|
32
26
|
|
33
|
-
def self.exercises
|
34
|
-
|
27
|
+
def self.exercises(path = "exercises")
|
28
|
+
service = Service.new(path)
|
29
|
+
service.exercises
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.rests(path = "rests")
|
33
|
+
service = Service.new(path)
|
34
|
+
service.rests
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.create_rest(mood_rating_1, mood_rating_2, content_selected, focus_interval, rest_interval, path = "rests")
|
38
|
+
service = Service.new(path)
|
39
|
+
service.create_rest(mood_rating_1, mood_rating_2, content_selected, focus_interval, rest_interval)
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
43
|
+
require 'som_timer/service'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class SomTimer::Service
|
2
|
+
def initialize(path)
|
3
|
+
@path = path
|
4
|
+
end
|
5
|
+
|
6
|
+
def timer
|
7
|
+
to_json("#{@path}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def exercises
|
11
|
+
to_json("#{@path}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def rand_exercise(duration, category)
|
15
|
+
to_json("#{@path}?duration=#{duration}&category=#{category}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_timer(work_interval, rest_interval, sound)
|
19
|
+
to_json_put(work_interval, rest_interval, sound)
|
20
|
+
end
|
21
|
+
|
22
|
+
def rests
|
23
|
+
to_json("#{@path}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_rest(mood_rating_1, mood_rating_2, content_selected, focus_interval, rest_interval)
|
27
|
+
to_json_post(mood_rating_1, mood_rating_2, content_selected, focus_interval, rest_interval)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def conn
|
33
|
+
Faraday.new("https://som-timer-be.herokuapp.com/api/")
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_json(url)
|
37
|
+
response = conn.get(url)
|
38
|
+
JSON.parse(response.body, symbolize_names: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_json_put(work_interval, rest_interval, sound)
|
42
|
+
response = conn.put do |req|
|
43
|
+
req.url "https://som-timer-be.herokuapp.com/api/#{@path}"
|
44
|
+
req.headers['Content-Type'] = 'application/json'
|
45
|
+
req.body = { "work_interval": "#{work_interval}", "rest_interval": "#{rest_interval}", "sound": "#{sound}" }.to_json
|
46
|
+
end
|
47
|
+
JSON.parse(response.body, symbolize_names: true)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_json_post(mood_rating_1, mood_rating_2, content_selected, focus_interval, rest_interval)
|
51
|
+
response = conn.post do |req|
|
52
|
+
req.url "https://som-timer-be.herokuapp.com/api/#{@path}"
|
53
|
+
req.headers['Content-Type'] = 'application/json'
|
54
|
+
req.body = { "mood_rating_1": "#{mood_rating_1}",
|
55
|
+
"mood_rating_2": "#{mood_rating_2}",
|
56
|
+
"content_selected": "#{content_selected}",
|
57
|
+
"focus_interval": "#{focus_interval}",
|
58
|
+
"rest_interval": "#{rest_interval}" }.to_json
|
59
|
+
end
|
60
|
+
JSON.parse(response.body, symbolize_names: true)
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: som-timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sienna Kopf
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: A ruby library for accessing API endpoints of the SomTimer application.
|
28
42
|
email: princess.kopf@gmail.com
|
29
43
|
executables: []
|
@@ -31,6 +45,7 @@ extensions: []
|
|
31
45
|
extra_rdoc_files: []
|
32
46
|
files:
|
33
47
|
- lib/som_timer.rb
|
48
|
+
- lib/som_timer/service.rb
|
34
49
|
homepage: https://rubygems.org/gems/som_timer
|
35
50
|
licenses:
|
36
51
|
- MIT
|