miracle_grow 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7cad2f0f12628b659f3a1d68befadb61a52fdc83
4
+ data.tar.gz: 4629fc55218c67e73b9d86377de769fe2b7b38ae
5
+ SHA512:
6
+ metadata.gz: ff86eb59861dcf8634b91293d76bcd525e6ec3fe9bf5d24a9c0213b9da48fa57f64c5025b21cfdc08df30c9690d3d71a3330f7b64b0566140b0821682e483ce6
7
+ data.tar.gz: 96892d5ebc071cfd1b49e9341faa425d42c93273b20f29be2a76bcddc1b7f50105e18391daf80fa107ef1debcd8fb4761ef84424e4cada197912717a06bb5ca9
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in miracle_grow.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ben Lewis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # Miracle Grow
2
+ - A gem for the MyGarden API
3
+
4
+ # Info:
5
+ - Consumer Key: 144395ac711b0e0689b7177f0fe95883
6
+ - Consumer Secret: ddecf54277a43b66fd727b43b5942b7a
7
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :test do
4
+ Dir['./test/**/*_test.rb'].each do |file|
5
+ system("ruby #{file}")
6
+ end
7
+ end
@@ -0,0 +1,59 @@
1
+ module MiracleGrow
2
+ class Plant
3
+ class << self
4
+
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
+ def all_the_plants
21
+ response = Faraday.get("http://localhost:8080/api/v1/plants")
22
+ JSON.parse(response.body)
23
+ end
24
+
25
+ def all_plant_names
26
+ all_the_plants.map {|plant| plant["name"] }
27
+ end
28
+
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
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module MiracleGrow
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "miracle_grow/version"
2
+ require "miracle_grow/plant"
3
+
4
+ module MiracleGrow
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'miracle_grow/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "miracle_grow"
8
+ spec.version = MiracleGrow::VERSION
9
+ spec.authors = ["Ben Lewinsky", "The Watts", "Tyrinx", "Lucasarts"]
10
+ spec.email = ["bennlewis@gmail.com", "reg@nathanielwatts.com", "tyler.stephen.long@gmail.com", "lukemartinez@gmail.com"]
11
+ spec.description = "This is a gem to wrap the Planting Season API"
12
+ spec.summary = "This is a gem to wrap the Planting Season API"
13
+ spec.homepage = "https://github.com/VirginSoil/miracle_grow"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+
25
+ spec.add_dependency "json"
26
+ spec.add_dependency "faraday"
27
+ end
@@ -0,0 +1,7 @@
1
+ require './test/test_helper'
2
+
3
+ class MiracleGrowTest < Minitest::Test
4
+ def test_the_plants_can_be_gitted
5
+ assert MiracleGrow::Plant.get_the_plants
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require './lib/miracle_grow.rb'
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miracle_grow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ben Lewinsky
8
+ - The Watts
9
+ - Tyrinx
10
+ - Lucasarts
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2014-02-12 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: minitest
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: json
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: faraday
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ description: This is a gem to wrap the Planting Season API
87
+ email:
88
+ - bennlewis@gmail.com
89
+ - reg@nathanielwatts.com
90
+ - tyler.stephen.long@gmail.com
91
+ - lukemartinez@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - .gitignore
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - lib/miracle_grow.rb
102
+ - lib/miracle_grow/plant.rb
103
+ - lib/miracle_grow/version.rb
104
+ - miracle_grow.gemspec
105
+ - test/miracle_grow_test.rb
106
+ - test/test_helper.rb
107
+ homepage: https://github.com/VirginSoil/miracle_grow
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.1.11
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: This is a gem to wrap the Planting Season API
131
+ test_files:
132
+ - test/miracle_grow_test.rb
133
+ - test/test_helper.rb
134
+ has_rdoc: