miracle_grow 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cad2f0f12628b659f3a1d68befadb61a52fdc83
4
- data.tar.gz: 4629fc55218c67e73b9d86377de769fe2b7b38ae
3
+ metadata.gz: 58c24968c2b9282407f819e219a78cd2afe4af3d
4
+ data.tar.gz: af0c11ec1f793ab87affcc664bf74698b45bc53c
5
5
  SHA512:
6
- metadata.gz: ff86eb59861dcf8634b91293d76bcd525e6ec3fe9bf5d24a9c0213b9da48fa57f64c5025b21cfdc08df30c9690d3d71a3330f7b64b0566140b0821682e483ce6
7
- data.tar.gz: 96892d5ebc071cfd1b49e9341faa425d42c93273b20f29be2a76bcddc1b7f50105e18391daf80fa107ef1debcd8fb4761ef84424e4cada197912717a06bb5ca9
6
+ metadata.gz: 517980c85571326da36bf50d4fa25915de0a8933550bedc3c499b9ed936f2c044bcf45fcf122959ee5eb75857e0dbd2435b88acf1bd90aef0ac30021e260cc59
7
+ data.tar.gz: 11d1d1125a702bf600b794ae49089205bdce98a724e2d208a6070fc27e986715852fb68e9c97df3090463d9ba46036e1e885ed5f97ec91874cc3420a57746f2d
@@ -0,0 +1,48 @@
1
+ module MiracleGrow
2
+
3
+ class Bed
4
+ class << self
5
+
6
+ def patch_bed(params)
7
+ Faraday.put("http://localhost:8080/api/v1/beds/#{(params[:id])}") do |req|
8
+ request = params
9
+ req.body = params
10
+ end
11
+ end
12
+
13
+ def current_users_beds(uid)
14
+ response = Faraday.get("http://localhost:8080/api/v1/beds/for_user/#{uid}")
15
+ JSON.parse(response.body)
16
+ end
17
+
18
+ def default_bed(uid)
19
+ response = Faraday.get("http://localhost:8080/api/v1/beds/default_for_user/#{uid}")
20
+ JSON.parse(response.body)
21
+ end
22
+
23
+ def show_bed(id)
24
+ response = Faraday.get("http://localhost:8080/api/v1/beds/#{id}")
25
+ JSON.parse(response.body)
26
+ end
27
+
28
+ def find_neighbors(bed)
29
+ if current_users_beds.length > 0
30
+ i = current_users_beds.index(bed)
31
+ if current_users_beds[i + 1]
32
+ @next = current_users_beds[i + 1]
33
+ else
34
+ @next = current_users_beds[0]
35
+ end
36
+
37
+ if current_users_beds[i-1]
38
+ @prev = current_users_beds[i - 1]
39
+ else
40
+ @prev = current_users_beds[-1]
41
+ end
42
+ end
43
+ [@next, @prev]
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -1,22 +1,8 @@
1
1
  module MiracleGrow
2
+
2
3
  class Plant
3
4
  class << self
4
5
 
5
- def current_users_beds(uid)
6
- response = Faraday.get("http://localhost:8080/api/v1/beds/for_user/#{uid}")
7
- JSON.parse(response.body)
8
- end
9
-
10
- def default_bed(uid)
11
- response = Faraday.get("http://localhost:8080/api/v1/beds/default_for_user/#{uid}")
12
- JSON.parse(response.body)
13
- end
14
-
15
- def show_bed(id)
16
- response = Faraday.get("http://localhost:8080/api/v1/beds/#{id}")
17
- JSON.parse(response.body)
18
- end
19
-
20
6
  def all_the_plants
21
7
  response = Faraday.get("http://localhost:8080/api/v1/plants")
22
8
  JSON.parse(response.body)
@@ -26,34 +12,6 @@ module MiracleGrow
26
12
  all_the_plants.map {|plant| plant["name"] }
27
13
  end
28
14
 
29
- def plantings_for_bed(bed)
30
- response = Faraday.get("http://localhost:8080/api/v1/plantings/for_bed/#{bed['id']}")
31
- plantings = JSON.parse(response.body)
32
- end
33
-
34
- def taken(bed)
35
- plantings_for_bed(bed).map do |planting|
36
- [planting["x_coord"].to_s, planting["y_coord"].to_s, planting["slug"].to_s]
37
- end
38
- end
39
-
40
- def find_neighbors(bed)
41
- if current_users_beds.length > 0
42
- i = current_users_beds.index(bed)
43
- if current_users_beds[i + 1]
44
- @next = current_users_beds[i + 1]
45
- else
46
- @next = current_users_beds[0]
47
- end
48
-
49
- if current_users_beds[i-1]
50
- @prev = current_users_beds[i - 1]
51
- else
52
- @prev = current_users_beds[-1]
53
- end
54
- end
55
- [@next, @prev]
56
- end
57
15
  end
58
16
  end
59
17
  end
@@ -0,0 +1,19 @@
1
+ module MiracleGrow
2
+
3
+ class Planting
4
+ class << self
5
+
6
+ def plantings_for_bed(id)
7
+ response = Faraday.get("http://localhost:8080/api/v1/plantings/for_bed/#{bed['id']}")
8
+ plantings = JSON.parse(response.body)
9
+ end
10
+
11
+ def taken(bed_id)
12
+ plantings_for_bed(bed_id).map do |planting|
13
+ [planting["x_coord"].to_s, planting["y_coord"].to_s, planting["slug"].to_s]
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module MiracleGrow
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/miracle_grow.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "miracle_grow/version"
2
2
  require "miracle_grow/plant"
3
+ require "miracle_grow/planting"
4
+ require "miracle_grow/bed"
3
5
 
4
6
  module MiracleGrow
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miracle_grow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Lewinsky
@@ -99,7 +99,9 @@ files:
99
99
  - README.md
100
100
  - Rakefile
101
101
  - lib/miracle_grow.rb
102
+ - lib/miracle_grow/bed.rb
102
103
  - lib/miracle_grow/plant.rb
104
+ - lib/miracle_grow/planting.rb
103
105
  - lib/miracle_grow/version.rb
104
106
  - miracle_grow.gemspec
105
107
  - test/miracle_grow_test.rb