cropio-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/README.md +38 -0
  7. data/Rakefile +1 -0
  8. data/bin/console +7 -0
  9. data/bin/login +19 -0
  10. data/bin/setup +7 -0
  11. data/cropio-ruby.gemspec +28 -0
  12. data/lib/cropio/connection/authenticable.rb +61 -0
  13. data/lib/cropio/connection/configurable.rb +24 -0
  14. data/lib/cropio/connection/proxiable.rb +57 -0
  15. data/lib/cropio/connection/proxy.rb +11 -0
  16. data/lib/cropio/connection.rb +9 -0
  17. data/lib/cropio/misc/string_inflector.rb +23 -0
  18. data/lib/cropio/misc.rb +1 -0
  19. data/lib/cropio/resource/attributes.rb +74 -0
  20. data/lib/cropio/resource/base.rb +96 -0
  21. data/lib/cropio/resource.rb +7 -0
  22. data/lib/cropio/resources/additional_object.rb +6 -0
  23. data/lib/cropio/resources/agri_work_plan.rb +6 -0
  24. data/lib/cropio/resources/agri_work_plan_application_mix_item.rb +6 -0
  25. data/lib/cropio/resources/agro_operation.rb +6 -0
  26. data/lib/cropio/resources/application_mix_item.rb +6 -0
  27. data/lib/cropio/resources/avatar.rb +6 -0
  28. data/lib/cropio/resources/chemical.rb +6 -0
  29. data/lib/cropio/resources/crop.rb +6 -0
  30. data/lib/cropio/resources/fertilizer.rb +6 -0
  31. data/lib/cropio/resources/field.rb +6 -0
  32. data/lib/cropio/resources/field_group.rb +6 -0
  33. data/lib/cropio/resources/field_scout_report.rb +6 -0
  34. data/lib/cropio/resources/field_scout_report_threat_mapping_item.rb +6 -0
  35. data/lib/cropio/resources/field_shape.rb +6 -0
  36. data/lib/cropio/resources/group_folder.rb +6 -0
  37. data/lib/cropio/resources/harvest_weighing.rb +6 -0
  38. data/lib/cropio/resources/historical_value.rb +6 -0
  39. data/lib/cropio/resources/history_item.rb +6 -0
  40. data/lib/cropio/resources/implement.rb +6 -0
  41. data/lib/cropio/resources/machine.rb +6 -0
  42. data/lib/cropio/resources/machine_group.rb +6 -0
  43. data/lib/cropio/resources/machine_task.rb +6 -0
  44. data/lib/cropio/resources/machine_task_agro_operation_mapping_item.rb +6 -0
  45. data/lib/cropio/resources/note.rb +6 -0
  46. data/lib/cropio/resources/plant_threat.rb +6 -0
  47. data/lib/cropio/resources/satellite_image.rb +6 -0
  48. data/lib/cropio/resources/seed.rb +6 -0
  49. data/lib/cropio/resources/user.rb +6 -0
  50. data/lib/cropio/resources.rb +33 -0
  51. data/lib/cropio/version.rb +3 -0
  52. data/lib/cropio.rb +23 -0
  53. metadata +178 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25080162e2321540d9afef974e98a51a4c47dc05
4
+ data.tar.gz: b855bcb0aa6ff3dc79d3f736d9da56646efc2ae1
5
+ SHA512:
6
+ metadata.gz: f70244336a238b35fcbdb552edbcf5f962de80d91aafbdb64a673f8abc39f748b8212242f372e0d331a5633e24d4d2b0bb2a0db617d1b6bb703eb349c10abac1
7
+ data.tar.gz: 8bc77ab8e26b55f5a4bb222db8e475ddc7a6bd2424f44fa9c6d50087ded61f1cfce89cf9075c5700d7404bdaec072870edfe3e51d7e87b188b95a09214bffa91
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cropio-ruby.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Cropio::Ruby
2
+
3
+ Cropio-Ruby provides simple ActiveRecord-like wrappings for Cropio API.
4
+ Currently it supports [Cropio APIv3](http://docs.cropioapiv3.apiary.io/).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'cropio-ruby'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install cropio-ruby
21
+
22
+ ## Usage
23
+
24
+ You
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/cropio/cropio-ruby/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cropio"
5
+
6
+ require "pry"
7
+ Pry.start
data/bin/login ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "byebug"
5
+ require "cropio"
6
+
7
+ require "pry"
8
+
9
+ Cropio.credentials = {}.tap do |c|
10
+ print "Enter your Cropio email: "
11
+ c[:email] = STDIN.gets.chomp
12
+
13
+ print "Entrer your Cropio password: "
14
+ c[:password] = STDIN.noecho(&:gets).chomp
15
+
16
+ puts
17
+ end
18
+
19
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -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 'cropio/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cropio-ruby"
8
+ spec.version = Cropio::VERSION
9
+ spec.authors = ["Sergey Vernidub"]
10
+ spec.email = ["info@cropio.com"]
11
+
12
+ spec.summary = %q{Cropio API bindings for Ruby}
13
+ spec.description = %q{Cropio-Ruby provides simple ActiveRecord-like wrappings for Cropio API}
14
+ spec.homepage = "https://cropio.com"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'json'
22
+ spec.add_dependency 'rest-client'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "byebug"
28
+ end
@@ -0,0 +1,61 @@
1
+ module Cropio
2
+ module Connection
3
+ module Authenticable
4
+ def authenticate!
5
+ auth_request
6
+ end
7
+
8
+ protected
9
+
10
+ def authenticate_before(*methods)
11
+ methods.each do |method_name|
12
+ unauthentificated_method = method(method_name)
13
+ singleton_class.send(:define_method, method_name) do |*args|
14
+ authenticate! if !authenticated?
15
+ unauthentificated_method.call(*args)
16
+ end
17
+ end
18
+ end
19
+
20
+ def auth_request
21
+ process_result RestClient.post(url_for('sign_in'),
22
+ auth_request_params.to_json,
23
+ authentication_headers)
24
+ rescue RestClient::Unauthorized => e
25
+ process_result(e.http_body)
26
+ end
27
+
28
+ def process_result(result)
29
+ result = JSON.parse(result)
30
+
31
+ if result['success']
32
+ Cropio.credentials.api_token = result['user_api_token']
33
+ true
34
+ else
35
+ fail 'Access to Cropio denied.'
36
+ end
37
+ end
38
+
39
+ def auth_request_params
40
+ {
41
+ user_login: {
42
+ email: Cropio.credentials.email,
43
+ password: Cropio.credentials.password
44
+ }
45
+ }
46
+ rescue NoMethodError => e
47
+ if %i(email password).include?(e.name)
48
+ fail "Cropio credentials is not specified: #{e.name}"
49
+ else
50
+ raise e
51
+ end
52
+ end
53
+
54
+ def authenticated?
55
+ !Cropio.credentials.api_token.nil?
56
+ rescue NoMethodError => e
57
+ e.name == :api_token ? false : raise(e)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,24 @@
1
+ module Cropio
2
+ module Connection
3
+ module Configurable
4
+
5
+ BASE_URL = 'https://cropio.com/api/v3'
6
+
7
+ protected
8
+
9
+ def headers
10
+ authenticated? ? authenticated_headers : authentication_headers
11
+ end
12
+
13
+ def authentication_headers
14
+ { content_type: :json, accept: :json }
15
+ end
16
+
17
+ def authenticated_headers
18
+ authentication_headers.merge({
19
+ 'X-User-Api-Token' => Cropio.credentials.api_token
20
+ })
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ require'rest-client'
2
+
3
+ module Cropio
4
+ module Connection
5
+ module Proxiable
6
+ def get(resource, query={})
7
+ proxy(method: :get, url: url_for(resource), headers: {params: query})
8
+ end
9
+
10
+ def post(resource, data)
11
+ proxy(method: :post, url: url_for(resource), data: data)
12
+ end
13
+
14
+ def patch(resource, data)
15
+ proxy(method: :patch, url: url_for(resource), data: data)
16
+ end
17
+
18
+ def delete(resource)
19
+ proxy(method: :delete, url: url_for(resource))
20
+ end
21
+
22
+ protected
23
+
24
+ def url_for(resource)
25
+ "#{Cropio::Connection::Configurable::BASE_URL}/#{resource}"
26
+ end
27
+
28
+ def proxy(options)
29
+ options[:headers] ||= {}
30
+ options[:headers].merge!(headers)
31
+ res = send("proxy_#{options[:method]}", options)
32
+ options[:method].eql?(:delete) ? res : JSON.parse(res)
33
+ rescue RestClient::UnprocessableEntity => e
34
+ puts JSON.parse(e.http_body)
35
+ raise e
36
+ end
37
+
38
+ def proxy_get(options)
39
+ RestClient::Request.execute(options)
40
+ end
41
+
42
+ def proxy_post(options)
43
+ RestClient.post(options[:url],
44
+ {data: options[:data]}, options[:headers])
45
+ end
46
+
47
+ def proxy_patch(options)
48
+ RestClient.patch(options[:url],
49
+ {data: options[:data]}, options[:headers])
50
+ end
51
+
52
+ def proxy_delete(options)
53
+ RestClient.delete(options[:url], options[:headers])
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,11 @@
1
+ module Cropio
2
+ module Connection
3
+ class Proxy
4
+ extend Authenticable
5
+ extend Configurable
6
+ extend Proxiable
7
+
8
+ authenticate_before :get, :post, :patch, :delete
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require_relative './connection/configurable'
2
+ require_relative './connection/authenticable'
3
+ require_relative './connection/proxiable'
4
+ require_relative './connection/proxy'
5
+
6
+ module Cropio
7
+ module Connection
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module Cropio
2
+ class StringInflector
3
+ class << self
4
+ def underscore(string)
5
+ string
6
+ .gsub(/::/, '/')
7
+ .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
8
+ .gsub(/([a-z\d])([A-Z])/,'\1_\2')
9
+ .tr("-", "_")
10
+ .downcase
11
+ end
12
+
13
+ # simple implementation - for resources plural form only
14
+ def pluralize(string)
15
+ if string[-1] == 'y'
16
+ "#{ string[0..(string.length - 2)] }ies"
17
+ else
18
+ "#{ string }s"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ require_relative './misc/string_inflector'
@@ -0,0 +1,74 @@
1
+ module Cropio
2
+ module Resource
3
+ module Attributes
4
+ def self.included(base)
5
+ base.send(:attr_accessor, :attributes)
6
+ end
7
+
8
+ protected
9
+
10
+ def attributes
11
+ @attributes ||= {}
12
+ end
13
+
14
+ def attributes=(val)
15
+ @attributes = val
16
+ end
17
+
18
+ def define_attributes_accessors
19
+ attributes.each_key do |attribute_name|
20
+ next if attribute_defined?(attribute_name)
21
+ define_attribute_getter(attribute_name)
22
+ define_attribute_setter(attribute_name)
23
+ define_attribute_question(attribute_name)
24
+ defined!(attribute_name)
25
+ end
26
+ end
27
+
28
+ def attribute_defined?(attribute_name)
29
+ @defined_attr ||= {}
30
+ @defined_attr[attribute_name] ||= false
31
+ end
32
+
33
+ def defined!(attribute_name)
34
+ @defined_attr ||= {}
35
+ @defined_attr[attribute_name] = true
36
+ end
37
+
38
+ def define_attribute_getter(attribute_name)
39
+ eval "
40
+ def #{attribute_name}
41
+ attributes['#{attribute_name}']
42
+ end
43
+ "
44
+ end
45
+
46
+ def define_attribute_setter(attribute_name)
47
+ eval "
48
+ def #{attribute_name}=(val)
49
+ attributes['#{attribute_name}'] = val
50
+ end
51
+ "
52
+ end
53
+
54
+ def define_attribute_question(attribute_name)
55
+ eval "
56
+ def #{attribute_name}?
57
+ !attributes['#{attribute_name}'].nil?
58
+ end
59
+ "
60
+ end
61
+
62
+ def method_missing(name, *attrs, &block)
63
+ name = name.to_s
64
+ attr_name = name.gsub('=', '')
65
+ if attributes.has_key?(attr_name)
66
+ define_attributes_accessors
67
+ name == attr_name ? send(name) : send(name, attrs.first)
68
+ else
69
+ super
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,96 @@
1
+ module Cropio
2
+ module Resource
3
+ class Base
4
+ include Attributes
5
+
6
+ Proxy = Cropio::Connection::Proxy
7
+ Limit = 1000
8
+
9
+ def initialize(attributes={})
10
+ self.attributes = attributes
11
+ end
12
+
13
+ def self.resource_name
14
+ @resource_name ||= StringInflector.underscore(name.split('::').last)
15
+ end
16
+
17
+ def self.resources_name
18
+ @resources_name ||= StringInflector.pluralize(resource_name)
19
+ end
20
+
21
+ def self.all
22
+ to_instances(get_all_chunks)
23
+ end
24
+
25
+ def self.count
26
+ all.count
27
+ end
28
+
29
+ def self.select(options={})
30
+ end
31
+
32
+ def persisted?
33
+ if @persisted.nil?
34
+ @persisted = false
35
+ end
36
+
37
+ @persisted
38
+ end
39
+
40
+ def save
41
+ self.attributes = if persisted?
42
+ Proxy.patch("#{resources_name}/#{id}", attributes)
43
+ else
44
+ @persisted = true
45
+ Proxy.post(resources_name, attributes)
46
+ end
47
+ end
48
+
49
+ private
50
+ def resources_name
51
+ self.class.resources_name
52
+ end
53
+
54
+ def self.get_all_chunks(options={})
55
+ response = nil
56
+ buffer = []
57
+ limit = options[:limit] || (2 ** 32 - 1)
58
+ while is_data?(response) && limit > 0
59
+ chunk_size = limit < Limit ? limit : Limit
60
+ limit -= chunk_size
61
+ offset = buffer.any? ? buffer.last['id'] + 1 : 0
62
+ response = get_chunk(limit: chunk_size, from_id: offset)
63
+ buffer += response['data']
64
+ end
65
+ buffer
66
+ end
67
+
68
+ def self.is_data?(response=nil)
69
+ if response.nil?
70
+ true
71
+ else
72
+ response['meta']['response']['obtained_records'].nonzero?
73
+ end
74
+ end
75
+
76
+ def self.get_chunk(options)
77
+ Proxy.get(resources_name, limit: options[:limit],
78
+ from_id: options[:from_id])
79
+ end
80
+
81
+ def self.to_instances(attr_sets)
82
+ attr_sets.map do |attr_set|
83
+ to_instance(attr_set)
84
+ end
85
+ end
86
+
87
+ def self.to_instance(attr_set)
88
+ new(attr_set).tap do |resource|
89
+ resource.instance_eval do
90
+ @persisted = true
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,7 @@
1
+ require_relative './resource/attributes'
2
+ require_relative './resource/base'
3
+
4
+ module Cropio
5
+ module Resource
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class AdditionalObject < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class AgriWorkPlan < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class AgriWorkPlanApplicationMixItem < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class AgroOperation < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class ApplicationMixItem < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Avatar < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Chemical < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Crop < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Fertilizer < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Field < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class FieldGroup < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class FieldScoutReport < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class FieldScoutReportThreatMappingItem < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class FieldShape < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class GroupFolder < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class HarvestWeighing < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class HistoricalValue < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class HistoryItem < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Implement < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Machine < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class MachineGroup < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class MachineTask < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class MachineTaskAgroOperationMappingItem < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Note < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class PlantThreat < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class SatelliteImage < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class Seed < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cropio
2
+ module Resources
3
+ class User < Cropio::Resource::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,33 @@
1
+ require_relative './resources/additional_object'
2
+ require_relative './resources/agri_work_plan_application_mix_item'
3
+ require_relative './resources/agri_work_plan'
4
+ require_relative './resources/agro_operation'
5
+ require_relative './resources/application_mix_item'
6
+ require_relative './resources/avatar'
7
+ require_relative './resources/chemical'
8
+ require_relative './resources/crop'
9
+ require_relative './resources/fertilizer'
10
+ require_relative './resources/field_group'
11
+ require_relative './resources/field'
12
+ require_relative './resources/field_scout_report'
13
+ require_relative './resources/field_scout_report_threat_mapping_item'
14
+ require_relative './resources/field_shape'
15
+ require_relative './resources/group_folder'
16
+ require_relative './resources/harvest_weighing'
17
+ require_relative './resources/historical_value'
18
+ require_relative './resources/history_item'
19
+ require_relative './resources/implement'
20
+ require_relative './resources/machine_group'
21
+ require_relative './resources/machine'
22
+ require_relative './resources/machine_task_agro_operation_mapping_item'
23
+ require_relative './resources/machine_task'
24
+ require_relative './resources/note'
25
+ require_relative './resources/plant_threat'
26
+ require_relative './resources/satellite_image'
27
+ require_relative './resources/seed'
28
+ require_relative './resources/user'
29
+
30
+ module Cropio
31
+ module CropioResources
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Cropio
2
+ VERSION = "0.1.0"
3
+ end
data/lib/cropio.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'ostruct'
2
+ require 'cropio/misc'
3
+ require 'cropio/version'
4
+ require 'cropio/connection'
5
+ require 'cropio/resource'
6
+ require 'cropio/resources'
7
+
8
+ module Cropio
9
+ def self.credentials
10
+ @credentials
11
+ end
12
+
13
+ def self.credentials=(credentials)
14
+ case credentials
15
+ when Hash
16
+ @credentials = OpenStruct.new(credentials)
17
+ when OpenStruct
18
+ @credentials = credentials
19
+ else
20
+ fail 'Cropio credentials should be a Hash or OpenStruct.'
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cropio-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergey Vernidub
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Cropio-Ruby provides simple ActiveRecord-like wrappings for Cropio API
98
+ email:
99
+ - info@cropio.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/login
112
+ - bin/setup
113
+ - cropio-ruby.gemspec
114
+ - lib/cropio.rb
115
+ - lib/cropio/connection.rb
116
+ - lib/cropio/connection/authenticable.rb
117
+ - lib/cropio/connection/configurable.rb
118
+ - lib/cropio/connection/proxiable.rb
119
+ - lib/cropio/connection/proxy.rb
120
+ - lib/cropio/misc.rb
121
+ - lib/cropio/misc/string_inflector.rb
122
+ - lib/cropio/resource.rb
123
+ - lib/cropio/resource/attributes.rb
124
+ - lib/cropio/resource/base.rb
125
+ - lib/cropio/resources.rb
126
+ - lib/cropio/resources/additional_object.rb
127
+ - lib/cropio/resources/agri_work_plan.rb
128
+ - lib/cropio/resources/agri_work_plan_application_mix_item.rb
129
+ - lib/cropio/resources/agro_operation.rb
130
+ - lib/cropio/resources/application_mix_item.rb
131
+ - lib/cropio/resources/avatar.rb
132
+ - lib/cropio/resources/chemical.rb
133
+ - lib/cropio/resources/crop.rb
134
+ - lib/cropio/resources/fertilizer.rb
135
+ - lib/cropio/resources/field.rb
136
+ - lib/cropio/resources/field_group.rb
137
+ - lib/cropio/resources/field_scout_report.rb
138
+ - lib/cropio/resources/field_scout_report_threat_mapping_item.rb
139
+ - lib/cropio/resources/field_shape.rb
140
+ - lib/cropio/resources/group_folder.rb
141
+ - lib/cropio/resources/harvest_weighing.rb
142
+ - lib/cropio/resources/historical_value.rb
143
+ - lib/cropio/resources/history_item.rb
144
+ - lib/cropio/resources/implement.rb
145
+ - lib/cropio/resources/machine.rb
146
+ - lib/cropio/resources/machine_group.rb
147
+ - lib/cropio/resources/machine_task.rb
148
+ - lib/cropio/resources/machine_task_agro_operation_mapping_item.rb
149
+ - lib/cropio/resources/note.rb
150
+ - lib/cropio/resources/plant_threat.rb
151
+ - lib/cropio/resources/satellite_image.rb
152
+ - lib/cropio/resources/seed.rb
153
+ - lib/cropio/resources/user.rb
154
+ - lib/cropio/version.rb
155
+ homepage: https://cropio.com
156
+ licenses: []
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.4.8
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Cropio API bindings for Ruby
178
+ test_files: []