farmsense_wrapper 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28205b673a80fff3d4564a94af458d1fd05eea61
4
+ data.tar.gz: e1c3b9d562292412c8f1ac28c70b65c2e9b28f38
5
+ SHA512:
6
+ metadata.gz: 9994e3d734f6df512b9c0648f617947830e419a6117362e5d16af231693d4f0b1564d7b3a0cd6f09a0854e6557178ae6df51350715769c4a448a8350a4387783
7
+ data.tar.gz: 65f907130932bf041ff8563a95a526af73909dfb518f46af982152f77d5d949f1f27d6d5ab912a64b35f93d875659d8cdcb907266ec7a3cfebe8ae2fd68389dd
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ deploy:
5
+ provider: rubygems
6
+ api_key:
7
+ -secure: "pk9g0Eg/MzhyIA4ZmHKP9X+AnCzUukzkcsKUejxUt6C1F1t9YGkPE1wjpTvUIP/AjIQOmjgeIdsz8cEY/80/F9pcLy1zpN4Y7ORyXz7gTiKmA8nRplj9Nyr/GF++U/71EudHsUYiBzPZ4mRR4EoI7amLfMFHaXw65TE8kWfWf9o="
8
+ on:
9
+ tags: true
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in farmsense_wrapper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 cohart
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,29 @@
1
+ # FarmsenseWrapper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'farmsense_wrapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install farmsense_wrapper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/farmsense_wrapper/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'farmsense_wrapper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "farmsense_wrapper"
8
+ spec.version = FarmsenseWrapper::VERSION
9
+ spec.authors = ["cohart"]
10
+ spec.email = ["me@colin-hart.com"]
11
+ spec.summary = %q{A wrapper for the Farmsense API, which provides day lengths, frost dates, and moon phases}
12
+ spec.description = %q{This wrapper currently only provides methods for retunring nearest whether stations and frostdates in json format}
13
+ spec.homepage = "https://github.com/cohart/farmsense_wrapper"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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
+
22
+
23
+ spec.add_development_dependency 'bundler', "~> 1.6"
24
+ spec.add_development_dependency 'rake', '~> 0'
25
+ spec.add_development_dependency 'rspec', '~> 0'
26
+ spec.add_development_dependency 'pry'
27
+ spec.add_dependency 'httparty', '~> 0'
28
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'farmsense_wrapper/version'
2
+ require_relative 'farmsense_wrapper/stations'
3
+ require_relative 'farmsense_wrapper/frost_dates'
4
+ require 'httparty'
5
+
6
+ #return nearest station to your coordinates
7
+ module FarmSenseWrapper
8
+ include HTTParty
9
+ class << self
10
+
11
+ def stations(lat, long)
12
+ s = GetStation::Stations.new({latitude: lat, longitude: long})
13
+ s.display
14
+ end
15
+
16
+ # acquire station_id from method abov
17
+ # specify season with 1 for spring 2 for autumn
18
+
19
+ def dates(station_id, season)
20
+ d = FindFrostDates::FrostDates.new({station_id: station_id, season: season})
21
+ d.display
22
+ end
23
+ end
24
+ end
25
+
26
+
27
+
28
+ # TODO: a method that takes two arguments creates a new station object and outputs display
29
+ # OPTIMIZE: methods that parse probabilities
30
+ # OPTIMIZE: methods that pars dates and return a time object
@@ -0,0 +1,31 @@
1
+ # require 'httparty'
2
+ require 'json'
3
+
4
+ module FindFrostDates
5
+ class FrostDates
6
+ attr_reader :endpoint_url
7
+ attr_writer :station_id, :season
8
+ # this object gets initialized with a station id found in stations.rb and a season.
9
+ # 1 for spring, 2 for fall.
10
+ def initialize(args)
11
+ @station_id = args[:station_id]
12
+ @season = args[:season]
13
+ @endpoint_url = "http://farmsense-prod.apigee.net/v1/frostdates/probabilities/?station=#{@station_id}&season=#{@season}"
14
+ end
15
+
16
+ def display
17
+ get
18
+ @parsed_response
19
+ end
20
+
21
+ def get
22
+ raw = HTTParty.get(endpoint_url)
23
+ @parsed_response = parse(raw)
24
+ end
25
+
26
+ def parse(data)
27
+ JSON.parse(data)
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+
3
+ module GetStation
4
+ class Stations
5
+ attr_reader :endpoint_url
6
+ attr_writer :latitude, :longitude
7
+
8
+
9
+ def initialize(args)
10
+ @latitude = args[:latitude]
11
+ @longitude = args[:longitude]
12
+ @endpoint_url = "http://farmsense-prod.apigee.net/v1/frostdates/stations/?lat=#{@latitude}8&lon=#{@longitude}"
13
+ end
14
+
15
+ def display
16
+ get
17
+ @parsed_response
18
+ end
19
+
20
+ def get
21
+ raw = HTTParty.get(endpoint_url)
22
+ @parsed_response = parse(raw)
23
+ end
24
+
25
+ def parse(data)
26
+ JSON.parse(data)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module FarmsenseWrapper
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ require_relative '../lib/farmsense_wrapper/frost_dates'
3
+
4
+ describe FindFrostDates::FrostDates do
5
+ d = FindFrostDates::FrostDates.new({station_id: 506586, season: 2})
6
+ it "get should display parsed response" do
7
+ expect(d.display[0]).to be_instance_of(Hash)
8
+ end
9
+ end
@@ -0,0 +1,88 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ # require 'farmsense_wrapper'
5
+ require 'httparty'
6
+
7
+ # This file was generated by the `rspec --init` command. Conventionally, all
8
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
10
+ # file to always be loaded, without a need to explicitly require it in any files.
11
+ #
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # (such as loading up an entire rails app) will add to the boot time of your
15
+ # test suite on EVERY test run, even for an individual file that may not need
16
+ # all of that loaded.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # The settings below are suggested to provide a good initial experience
24
+ # with RSpec, but feel free to customize to your heart's content.
25
+ =begin
26
+ # These two settings work together to allow you to limit a spec run
27
+ # to individual examples or groups you care about by tagging them with
28
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
29
+ # get run.
30
+ config.filter_run :focus
31
+ config.run_all_when_everything_filtered = true
32
+
33
+ # Many RSpec users commonly either run the entire suite or an individual
34
+ # file, and it's useful to allow more verbose output when running an
35
+ # individual spec file.
36
+ if config.files_to_run.one?
37
+ # RSpec filters the backtrace by default so as not to be so noisy.
38
+ # This causes the full backtrace to be printed when running a single
39
+ # spec file (e.g. to troubleshoot a particular spec failure).
40
+ config.full_backtrace = true
41
+
42
+ # Use the documentation formatter for detailed output,
43
+ # unless a formatter has already been configured
44
+ # (e.g. via a command-line flag).
45
+ config.formatter = 'doc' if config.formatters.none?
46
+ end
47
+
48
+ # Print the 10 slowest examples and example groups at the
49
+ # end of the spec run, to help surface which specs are running
50
+ # particularly slow.
51
+ config.profile_examples = 10
52
+
53
+ # Run specs in random order to surface order dependencies. If you find an
54
+ # order dependency and want to debug it, you can fix the order by providing
55
+ # the seed, which is printed after each run.
56
+ # --seed 1234
57
+ config.order = :random
58
+
59
+ # Seed global randomization in this process using the `--seed` CLI option.
60
+ # Setting this allows you to use `--seed` to deterministically reproduce
61
+ # test failures related to randomization by passing the same `--seed` value
62
+ # as the one that triggered the failure.
63
+ Kernel.srand config.seed
64
+
65
+ # rspec-expectations config goes here. You can use an alternate
66
+ # assertion/expectation library such as wrong or the stdlib/minitest
67
+ # assertions if you prefer.
68
+ config.expect_with :rspec do |expectations|
69
+ # Enable only the newer, non-monkey-patching expect syntax.
70
+ # For more details, see:
71
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
72
+ expectations.syntax = :expect
73
+ end
74
+
75
+ # rspec-mocks config goes here. You can use an alternate test double
76
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
77
+ config.mock_with :rspec do |mocks|
78
+ # Enable only the newer, non-monkey-patching expect syntax.
79
+ # For more details, see:
80
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
81
+ mocks.syntax = :expect
82
+
83
+ # Prevents you from mocking or stubbing a method that does not exist on
84
+ # a real object. This is generally recommended.
85
+ mocks.verify_partial_doubles = true
86
+ end
87
+ =end
88
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ require_relative '../lib/farmsense_wrapper/stations'
3
+
4
+ describe GetStation::Stations do
5
+ s = GetStation::Stations.new({latitude: 42, longitude: -112})
6
+ stations = s.display
7
+ it "get should display parsed response" do
8
+ expect(stations[0]).to be_instance_of(Hash)
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: farmsense_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - cohart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: This wrapper currently only provides methods for retunring nearest whether
84
+ stations and frostdates in json format
85
+ email:
86
+ - me@colin-hart.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - farmsense_wrapper.gemspec
99
+ - lib/farmsense_wrapper.rb
100
+ - lib/farmsense_wrapper/frost_dates.rb
101
+ - lib/farmsense_wrapper/stations.rb
102
+ - lib/farmsense_wrapper/version.rb
103
+ - spec/frost_dates_spec.rb
104
+ - spec/spec_helper.rb
105
+ - spec/stations_spec.rb
106
+ homepage: https://github.com/cohart/farmsense_wrapper
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A wrapper for the Farmsense API, which provides day lengths, frost dates,
130
+ and moon phases
131
+ test_files:
132
+ - spec/frost_dates_spec.rb
133
+ - spec/spec_helper.rb
134
+ - spec/stations_spec.rb