plants 0.1.0

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
+ SHA256:
3
+ metadata.gz: b8e9b712b2177d93408282db2d2b6efc283fb9fbfb84d17d6fc80efcc58a710b
4
+ data.tar.gz: e51872144774793b602adac46640d515ae2a353a07e89fa3beb70d33b50a4ffc
5
+ SHA512:
6
+ metadata.gz: 3df27aab14d6ed43639c9837cbaa53b4ccf18790929af2f5966d25608735535057f43969c5185d7e4c4b0d7e578acf815ce2b7e30c144f1193760bed8a15ca9f
7
+ data.tar.gz: c3094796cde53a394b4b819047e1d1d38c492efb2e20d0b5c736f7ee891a46ce5eca065f43b2a063237fb215fdbf0a8921de19421b68b5cd2ad349c06ea7d31a
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --profile
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ plants
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-02-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at vhector.1337@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in plants.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem "rake", "~> 13.0"
10
+
11
+ gem "rspec", "~> 3.0"
12
+
13
+ gem "rubocop", "~> 1.21"
14
+
15
+ gem 'simplecov', '~> 0'
16
+
17
+ gem 'sord', '~> 6'
18
+
19
+ gem 'webmock', '~> 3'
20
+ end
data/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # Plants
2
+ Gem to interact with the [trefle](https://docs.trefle.io/reference) API.
3
+
4
+ ## Install
5
+ `spec.add_dependency 'plants', ~> 0`
6
+
7
+ ## Usage
8
+ You need an authorization token, [see this](https://docs.trefle.io/docs/guides/getting-started).
9
+ ```ruby
10
+ Plants.token = 'your token here'
11
+ Plants.list_plants # ...
12
+ ```
13
+
14
+ ### Endpoints
15
+ #### Corrections
16
+ ```ruby
17
+ # List
18
+ Plants.list_corrections
19
+
20
+ # Find
21
+ Plants.find_correction('correction')
22
+ ```
23
+
24
+ #### Distributions
25
+ ```ruby
26
+ # List
27
+ Plants.list_distributions
28
+
29
+ # Find
30
+ Plants.find_distribution('correction')
31
+ ```
32
+
33
+ #### Division Classes
34
+ ```ruby
35
+ # List
36
+ Plants.list_division_classes
37
+
38
+ # Find
39
+ Plants.find_division_class('class')
40
+ ```
41
+
42
+ #### Division Orders
43
+ ```ruby
44
+ # List
45
+ Plants.list_division_orders
46
+
47
+ # Find
48
+ Plants.find_division_order('order')
49
+ ```
50
+
51
+ #### Divisions
52
+ ```ruby
53
+ # List
54
+ Plants.list_divisions
55
+
56
+ # Find
57
+ Plants.find_division('division')
58
+ ```
59
+
60
+ #### Families
61
+ ```ruby
62
+ # List
63
+ Plants.list_families
64
+
65
+ # Find
66
+ Plants.find_family('family')
67
+ ```
68
+
69
+ #### Genus
70
+ ```ruby
71
+ # List
72
+ Plants.list_genera
73
+
74
+ # Find
75
+ Plants.find_genus('genus')
76
+ ```
77
+
78
+ #### Kingdoms
79
+ ```ruby
80
+ # List
81
+ Plants.list_kingdoms
82
+
83
+ # Find
84
+ Plants.find_kingdom('kingodm')
85
+ ```
86
+
87
+ #### Plants
88
+ ```ruby
89
+ # List
90
+ Plants.list_plants
91
+
92
+ # Find
93
+ Plants.find_plant('plant')
94
+
95
+ # Search
96
+ Plants.search_for_plant('plant')
97
+
98
+ # List for Genus
99
+ Plants.list_plants_for_genus('genus')
100
+
101
+ # List for Distribution Zone
102
+ Plants.list_plants_for_distribution_zone('zone')
103
+ ```
104
+
105
+ #### Species
106
+ ```ruby
107
+ # List
108
+ Plants.list_species
109
+
110
+ # Find
111
+ Plants.find_species('species')
112
+
113
+ # Search
114
+ Plants.search_for_species('species')
115
+ ```
116
+
117
+ #### Subkingdoms
118
+ ```ruby
119
+ # List
120
+ Plants.list_subkingdoms
121
+
122
+ # Find
123
+ Plants.find_subkingdom('subkingdom')
124
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ require 'http'
3
+
4
+ require 'plants/log'
5
+ require 'plants/config'
6
+ require 'plants/version'
7
+
8
+ module Plants
9
+ # HTTP Client
10
+ #
11
+ # @!attribute [r] config
12
+ # @return [Plants::Config]
13
+ #
14
+ class Client
15
+ # @return [String] Trefle API URL
16
+ URL = 'https://trefle.io/api/v1'
17
+
18
+ # @param config [Plants::Config]
19
+ def initialize(config = Config.new)
20
+ @config = config
21
+ end
22
+ attr_reader :config
23
+
24
+
25
+ # @param resource [String]
26
+ # @param params [Hash]
27
+ # @return [::HTTP::Response]
28
+ def get(resource, params: {})
29
+ params.merge!({ token: config.token }) if config.token
30
+ http.get("#{URL}/#{resource}", params: params)
31
+ end
32
+
33
+ private
34
+
35
+ # @return [::HTTP::Client]
36
+ def http
37
+ HTTP
38
+ .timeout(10)
39
+ .use(logging: { logger: Log.instance })
40
+ .headers({ 'User-Agent' => "Plants #{Plants::VERSION} ruby-#{RUBY_VERSION}" })
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,13 @@
1
+ module Plants
2
+ # Configuration class
3
+ #
4
+ # @!attribute token
5
+ # @return [String]
6
+ #
7
+ class Config
8
+ def initialize
9
+ @token = nil
10
+ end
11
+ attr_accessor :token
12
+ end
13
+ end
data/lib/plants/log.rb ADDED
@@ -0,0 +1,53 @@
1
+ require 'logger'
2
+
3
+ module Plants
4
+ # Simple split logger
5
+ class Log
6
+ def initialize
7
+ @stdout = Logger.new(STDOUT)
8
+ @stderr = Logger.new(STDERR)
9
+ end
10
+
11
+ # @param progname [String]
12
+ # @param block [Proc]
13
+ # @return [void]
14
+ def debug(progname = nil, &block)
15
+ @stdout.debug(progname, &block)
16
+ end
17
+
18
+ # @param progname [String]
19
+ # @param block [Proc]
20
+ # @return [void]
21
+ def info(progname = nil, &block)
22
+ @stdout.info(progname, &block)
23
+ end
24
+
25
+ # @param progname [String]
26
+ # @param block [Proc]
27
+ # @return [void]
28
+ def warn(progname = nil, &block)
29
+ @stderr.warn(progname, &block)
30
+ end
31
+
32
+ # @param progname [String]
33
+ # @param block [Proc]
34
+ # @return [void]
35
+ def error(progname = nil, &block)
36
+ @stderr.error(progname, &block)
37
+ end
38
+
39
+ # @param progname [String]
40
+ # @param block [Proc]
41
+ # @return [void]
42
+ def fatal(progname = nil, &block)
43
+ @stderr.fatal(progname, &block)
44
+ end
45
+
46
+ class << self
47
+ # @return [Plants::Log]
48
+ def instance
49
+ @_instance ||= new
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Corrections module
4
+ # @see https://docs.trefle.io/reference#tag/Corrections
5
+ module Corrections
6
+ # GET /corrections
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_corrections(params: {})
10
+ client.get('corrections', params: params)
11
+ end
12
+
13
+ # @param correction [String]
14
+ # @return [::HTTP::Response]
15
+ def find_correction(correction)
16
+ client.get("corrections/#{correction}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Distributions module
4
+ # @see https://docs.trefle.io/reference#tag/Distributions
5
+ module Distributions
6
+ # GET /distributions
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_distributions(params: {})
10
+ client.get('distributions', params: params)
11
+ end
12
+
13
+ # @param distribution [String]
14
+ # @return [::HTTP::Response]
15
+ def find_distribution(distribution)
16
+ client.get("distributions/#{distribution}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Division classes module
4
+ # @see https://docs.trefle.io/reference#tag/DivisionClasses
5
+ module DivisionClasses
6
+ # GET /division_classes
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_division_classes(params: {})
10
+ client.get('division_classes', params: params)
11
+ end
12
+
13
+ # @param division_class [String]
14
+ # @return [::HTTP::Response]
15
+ def find_division_class(division_class)
16
+ client.get("division_classes/#{division_class}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Division orders module
4
+ # @see https://docs.trefle.io/reference#tag/DivisionOrders
5
+ module DivisionOrders
6
+ # GET /division_orders
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_division_orders(params: {})
10
+ client.get('division_orders', params: params)
11
+ end
12
+
13
+ # @param division_order [String]
14
+ # @return [::HTTP::Response]
15
+ def find_division_order(division_order)
16
+ client.get("division_orders/#{division_order}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Divisions module
4
+ # @see https://docs.trefle.io/reference#tag/Divisions
5
+ module Divisions
6
+ # GET /divisions
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_divisions(params: {})
10
+ client.get('divisions', params: params)
11
+ end
12
+
13
+ # @param division [String]
14
+ # @return [::HTTP::Response]
15
+ def find_division(division)
16
+ client.get("divisions/#{division}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Families module
4
+ # @see https://docs.trefle.io/reference#tag/Families
5
+ module Families
6
+ # GET /families
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_families(params: {})
10
+ client.get('families', params: params)
11
+ end
12
+
13
+ # @param family [String]
14
+ # @return [::HTTP::Response]
15
+ def find_family(family)
16
+ client.get("families/#{family}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Genera module
4
+ # @see https://docs.trefle.io/reference#tag/Genus
5
+ module Genus
6
+ # GET /genus
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_genera(params: {})
10
+ client.get('genus', params: params)
11
+ end
12
+
13
+ # @param genus [String]
14
+ # @return [::HTTP::Response]
15
+ def find_genus(genus)
16
+ client.get("genus/#{genus}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Kingdoms module
4
+ # @see https://docs.trefle.io/reference#tag/Kingdoms
5
+ module Kingdoms
6
+ # GET /kingdoms
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_kingdoms(params: {})
10
+ client.get('kingdoms', params: params)
11
+ end
12
+
13
+ # @param kingdom [String]
14
+ # @return [::HTTP::Response]
15
+ def find_kingdom(kingdom)
16
+ client.get("kingdoms/#{kingdom}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ module Plants
2
+ module Resources
3
+ # Plants resource
4
+ # @see https://docs.trefle.io/reference#tag/Plants
5
+ module Plants
6
+ # GET /plants
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_plants(params: {})
10
+ client.get('plants', params: params)
11
+ end
12
+
13
+ # GET /plants/{plant}
14
+ # @param plant [String]
15
+ # @return [::HTTP::Response]
16
+ def find_plant(plant)
17
+ client.get("plants/#{plant}")
18
+ end
19
+
20
+ # @param plant [String]
21
+ # @param params [Hash]
22
+ # @return [::HTTP::Response]
23
+ def search_for_plant(plant, params: {})
24
+ client.get('plants/search', params: params.merge({ q: plant }))
25
+ end
26
+
27
+ # @param genus [String]
28
+ # @param params [Hash]
29
+ # @return [::HTTP::Response]
30
+ def list_plants_for_genus(genus, params: {})
31
+ client.get("genus/#{genus}/plants", params: params)
32
+ end
33
+
34
+ # @param zone [String]
35
+ # @param params [Hash]
36
+ # @return [::HTTP::Response]
37
+ def list_plants_for_distribution_zone(zone, params: {})
38
+ client.get("distributions/#{zone}/plants", params: params)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ module Plants
2
+ module Resources
3
+ # Species module
4
+ # @see https://docs.trefle.io/reference#tag/Species
5
+ module Species
6
+ # GET /species
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_species(params: {})
10
+ client.get('species', params: params)
11
+ end
12
+
13
+ # @param species [String]
14
+ # @return [::HTTP::Response]
15
+ def find_species(species)
16
+ client.get("species/#{species}")
17
+ end
18
+
19
+ # @param species [String]
20
+ # @return [::HTTP::Response]s
21
+ def search_for_species(species)
22
+ client.get("species/search", params: { q: species })
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ module Plants
2
+ module Resources
3
+ # Subkingdoms module
4
+ # @see https://docs.trefle.io/reference#tag/Subkingdoms
5
+ module Subkingdoms
6
+ # GET /subkingdoms
7
+ # @param params [Hash]
8
+ # @return [::HTTP::Response]
9
+ def list_subkingdoms(params: {})
10
+ client.get('subkingdoms', params: params)
11
+ end
12
+
13
+ # @param kingdom [String]
14
+ # @return [::HTTP::Response]
15
+ def find_subkingdom(kingdom)
16
+ client.get("subkingdoms/#{kingdom}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ require 'plants/resources/corrections'
2
+ require 'plants/resources/distributions'
3
+ require 'plants/resources/division_classes'
4
+ require 'plants/resources/division_orders'
5
+ require 'plants/resources/divisions'
6
+ require 'plants/resources/families'
7
+ require 'plants/resources/genus'
8
+ require 'plants/resources/kingdoms'
9
+ require 'plants/resources/plants'
10
+ require 'plants/resources/species'
11
+ require 'plants/resources/subkingdoms'
12
+
13
+ module Plants
14
+ # Resources 'container' module
15
+ module Resources
16
+ include Corrections
17
+ include Distributions
18
+ include DivisionClasses
19
+ include DivisionOrders
20
+ include Divisions
21
+ include Families
22
+ include Genus
23
+ include Kingdoms
24
+ include Plants
25
+ include Species
26
+ include Subkingdoms
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plants
4
+ # @return [String]
5
+ VERSION = "0.1.0"
6
+ end
data/lib/plants.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "plants/client"
4
+ require "plants/config"
5
+ require "plants/resources"
6
+ require "plants/version"
7
+
8
+ # Plants :)
9
+ module Plants
10
+ extend Plants::Resources
11
+
12
+ class << self
13
+
14
+ # @param new_value [String]
15
+ # @return [void]
16
+ def token=(new_value)
17
+ client.config.token = new_value
18
+ end
19
+
20
+ # @return [Plants::Config]
21
+ def config
22
+ client.config
23
+ end
24
+
25
+ private
26
+
27
+ # @return [Plants::Client]
28
+ def client
29
+ @_client ||= Client.new
30
+ end
31
+ end
32
+ end
data/plants.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/plants/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "plants"
7
+ spec.version = Plants::VERSION
8
+ spec.authors = ["Xero"]
9
+ spec.email = ["vhector.1337@gmail.com"]
10
+
11
+ spec.summary = "Plants API gem."
12
+ spec.description = "Gem to interact with Trefle API."
13
+ spec.homepage = "https://github.com/one-m1nd/plants"
14
+ spec.required_ruby_version = ">= 3"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(__dir__) do
21
+ `git ls-files -z`.split("\x0").reject do |f|
22
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
23
+ end
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ spec.add_dependency "http", "~> 5"
31
+
32
+ # For more information and examples about making a new gem, check out our
33
+ # guide at: https://bundler.io/guides/creating_gem.html
34
+ end
data/sig/plants.rbs ADDED
@@ -0,0 +1,381 @@
1
+ # Plants :)
2
+ module Plants
3
+ extend Plants::Resources
4
+ VERSION: String
5
+
6
+ # _@param_ `new_value`
7
+ def self.token=: (String new_value) -> void
8
+
9
+ def self.config: () -> Plants::Config
10
+
11
+ def self.client: () -> Plants::Client
12
+
13
+ # GET /subkingdoms
14
+ #
15
+ # _@param_ `params`
16
+ def self.list_subkingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
17
+
18
+ # _@param_ `kingdom`
19
+ def self.find_subkingdom: (String kingdom) -> ::HTTP::Response
20
+
21
+ # GET /species
22
+ #
23
+ # _@param_ `params`
24
+ def self.list_species: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
25
+
26
+ # _@param_ `species`
27
+ def self.find_species: (String species) -> ::HTTP::Response
28
+
29
+ # _@param_ `species`
30
+ #
31
+ # _@return_ — s
32
+ def self.search_for_species: (String species) -> ::HTTP::Response
33
+
34
+ # GET /kingdoms
35
+ #
36
+ # _@param_ `params`
37
+ def self.list_kingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
38
+
39
+ # _@param_ `kingdom`
40
+ def self.find_kingdom: (String kingdom) -> ::HTTP::Response
41
+
42
+ # GET /genus
43
+ #
44
+ # _@param_ `params`
45
+ def self.list_genera: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
46
+
47
+ # _@param_ `genus`
48
+ def self.find_genus: (String genus) -> ::HTTP::Response
49
+
50
+ # GET /families
51
+ #
52
+ # _@param_ `params`
53
+ def self.list_families: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
54
+
55
+ # _@param_ `family`
56
+ def self.find_family: (String family) -> ::HTTP::Response
57
+
58
+ # GET /divisions
59
+ #
60
+ # _@param_ `params`
61
+ def self.list_divisions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
62
+
63
+ # _@param_ `division`
64
+ def self.find_division: (String division) -> ::HTTP::Response
65
+
66
+ # GET /division_orders
67
+ #
68
+ # _@param_ `params`
69
+ def self.list_division_orders: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
70
+
71
+ # _@param_ `division_order`
72
+ def self.find_division_order: (String division_order) -> ::HTTP::Response
73
+
74
+ # GET /division_classes
75
+ #
76
+ # _@param_ `params`
77
+ def self.list_division_classes: (::Hash[untyped, untyped] params) -> ::HTTP::Response
78
+
79
+ # _@param_ `division_class`
80
+ def self.find_division_class: (String division_class) -> ::HTTP::Response
81
+
82
+ # GET /distributions
83
+ #
84
+ # _@param_ `params`
85
+ def self.list_distributions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
86
+
87
+ # _@param_ `distribution`
88
+ def self.find_distribution: (String distribution) -> ::HTTP::Response
89
+
90
+ # GET /corrections
91
+ #
92
+ # _@param_ `params`
93
+ def self.list_corrections: (::Hash[untyped, untyped] params) -> ::HTTP::Response
94
+
95
+ # _@param_ `correction`
96
+ def self.find_correction: (String correction) -> ::HTTP::Response
97
+
98
+ # HTTP Client
99
+ #
100
+ # @!attribute [r] config
101
+ # @return [Plants::Config]
102
+ class Client
103
+ URL: String
104
+
105
+ # _@param_ `config`
106
+ def initialize: (?Plants::Config config) -> void
107
+
108
+ # _@param_ `resource`
109
+ #
110
+ # _@param_ `params`
111
+ def get: (String resource, ?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
112
+
113
+ def http: () -> ::HTTP::Client
114
+
115
+ attr_reader config: Plants::Config
116
+ end
117
+
118
+ # Configuration class
119
+ #
120
+ # @!attribute token
121
+ # @return [String]
122
+ class Config
123
+ def initialize: () -> void
124
+
125
+ attr_accessor token: String
126
+ end
127
+
128
+ # Resources 'container' module
129
+ module Resources
130
+ include Plants::Resources::Corrections
131
+ include Plants::Resources::Distributions
132
+ include Plants::Resources::DivisionClasses
133
+ include Plants::Resources::DivisionOrders
134
+ include Plants::Resources::Divisions
135
+ include Plants::Resources::Families
136
+ include Plants::Resources::Genus
137
+ include Plants::Resources::Kingdoms
138
+ include Plants
139
+ include Plants::Resources::Species
140
+ include Plants::Resources::Subkingdoms
141
+
142
+ # GET /subkingdoms
143
+ #
144
+ # _@param_ `params`
145
+ def list_subkingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
146
+
147
+ # _@param_ `kingdom`
148
+ def find_subkingdom: (String kingdom) -> ::HTTP::Response
149
+
150
+ # GET /species
151
+ #
152
+ # _@param_ `params`
153
+ def list_species: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
154
+
155
+ # _@param_ `species`
156
+ def find_species: (String species) -> ::HTTP::Response
157
+
158
+ # _@param_ `species`
159
+ #
160
+ # _@return_ — s
161
+ def search_for_species: (String species) -> ::HTTP::Response
162
+
163
+ # GET /kingdoms
164
+ #
165
+ # _@param_ `params`
166
+ def list_kingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
167
+
168
+ # _@param_ `kingdom`
169
+ def find_kingdom: (String kingdom) -> ::HTTP::Response
170
+
171
+ # GET /genus
172
+ #
173
+ # _@param_ `params`
174
+ def list_genera: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
175
+
176
+ # _@param_ `genus`
177
+ def find_genus: (String genus) -> ::HTTP::Response
178
+
179
+ # GET /families
180
+ #
181
+ # _@param_ `params`
182
+ def list_families: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
183
+
184
+ # _@param_ `family`
185
+ def find_family: (String family) -> ::HTTP::Response
186
+
187
+ # GET /divisions
188
+ #
189
+ # _@param_ `params`
190
+ def list_divisions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
191
+
192
+ # _@param_ `division`
193
+ def find_division: (String division) -> ::HTTP::Response
194
+
195
+ # GET /division_orders
196
+ #
197
+ # _@param_ `params`
198
+ def list_division_orders: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
199
+
200
+ # _@param_ `division_order`
201
+ def find_division_order: (String division_order) -> ::HTTP::Response
202
+
203
+ # GET /division_classes
204
+ #
205
+ # _@param_ `params`
206
+ def list_division_classes: (::Hash[untyped, untyped] params) -> ::HTTP::Response
207
+
208
+ # _@param_ `division_class`
209
+ def find_division_class: (String division_class) -> ::HTTP::Response
210
+
211
+ # GET /distributions
212
+ #
213
+ # _@param_ `params`
214
+ def list_distributions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
215
+
216
+ # _@param_ `distribution`
217
+ def find_distribution: (String distribution) -> ::HTTP::Response
218
+
219
+ # GET /corrections
220
+ #
221
+ # _@param_ `params`
222
+ def list_corrections: (::Hash[untyped, untyped] params) -> ::HTTP::Response
223
+
224
+ # _@param_ `correction`
225
+ def find_correction: (String correction) -> ::HTTP::Response
226
+
227
+ # Genera module
228
+ # @see https://docs.trefle.io/reference#tag/Genus
229
+ module Genus
230
+ # GET /genus
231
+ #
232
+ # _@param_ `params`
233
+ def list_genera: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
234
+
235
+ # _@param_ `genus`
236
+ def find_genus: (String genus) -> ::HTTP::Response
237
+ end
238
+
239
+ # Plants resource
240
+ # @see https://docs.trefle.io/reference#tag/Plants
241
+ module Plants
242
+ # GET /plants
243
+ #
244
+ # _@param_ `params`
245
+ def list_plants: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
246
+
247
+ # GET /plants/{plant}
248
+ #
249
+ # _@param_ `plant`
250
+ def find_plant: (String plant) -> ::HTTP::Response
251
+
252
+ # _@param_ `plant`
253
+ #
254
+ # _@param_ `params`
255
+ def search_for_plant: (String plant, ?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
256
+
257
+ # _@param_ `genus`
258
+ #
259
+ # _@param_ `params`
260
+ def list_plants_for_genus: (String genus, ?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
261
+
262
+ # _@param_ `zone`
263
+ #
264
+ # _@param_ `params`
265
+ def list_plants_for_distribution_zone: (String zone, ?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
266
+ end
267
+
268
+ # Species module
269
+ # @see https://docs.trefle.io/reference#tag/Species
270
+ module Species
271
+ # GET /species
272
+ #
273
+ # _@param_ `params`
274
+ def list_species: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
275
+
276
+ # _@param_ `species`
277
+ def find_species: (String species) -> ::HTTP::Response
278
+
279
+ # _@param_ `species`
280
+ #
281
+ # _@return_ — s
282
+ def search_for_species: (String species) -> ::HTTP::Response
283
+ end
284
+
285
+ # Families module
286
+ # @see https://docs.trefle.io/reference#tag/Families
287
+ module Families
288
+ # GET /families
289
+ #
290
+ # _@param_ `params`
291
+ def list_families: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
292
+
293
+ # _@param_ `family`
294
+ def find_family: (String family) -> ::HTTP::Response
295
+ end
296
+
297
+ # Kingdoms module
298
+ # @see https://docs.trefle.io/reference#tag/Kingdoms
299
+ module Kingdoms
300
+ # GET /kingdoms
301
+ #
302
+ # _@param_ `params`
303
+ def list_kingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
304
+
305
+ # _@param_ `kingdom`
306
+ def find_kingdom: (String kingdom) -> ::HTTP::Response
307
+ end
308
+
309
+ # Divisions module
310
+ # @see https://docs.trefle.io/reference#tag/Divisions
311
+ module Divisions
312
+ # GET /divisions
313
+ #
314
+ # _@param_ `params`
315
+ def list_divisions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
316
+
317
+ # _@param_ `division`
318
+ def find_division: (String division) -> ::HTTP::Response
319
+ end
320
+
321
+ # Corrections module
322
+ # @see https://docs.trefle.io/reference#tag/Corrections
323
+ module Corrections
324
+ # GET /corrections
325
+ #
326
+ # _@param_ `params`
327
+ def list_corrections: (::Hash[untyped, untyped] params) -> ::HTTP::Response
328
+
329
+ # _@param_ `correction`
330
+ def find_correction: (String correction) -> ::HTTP::Response
331
+ end
332
+
333
+ # Subkingdoms module
334
+ # @see https://docs.trefle.io/reference#tag/Subkingdoms
335
+ module Subkingdoms
336
+ # GET /subkingdoms
337
+ #
338
+ # _@param_ `params`
339
+ def list_subkingdoms: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
340
+
341
+ # _@param_ `kingdom`
342
+ def find_subkingdom: (String kingdom) -> ::HTTP::Response
343
+ end
344
+
345
+ # Distributions module
346
+ # @see https://docs.trefle.io/reference#tag/Distributions
347
+ module Distributions
348
+ # GET /distributions
349
+ #
350
+ # _@param_ `params`
351
+ def list_distributions: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
352
+
353
+ # _@param_ `distribution`
354
+ def find_distribution: (String distribution) -> ::HTTP::Response
355
+ end
356
+
357
+ # Division orders module
358
+ # @see https://docs.trefle.io/reference#tag/DivisionOrders
359
+ module DivisionOrders
360
+ # GET /division_orders
361
+ #
362
+ # _@param_ `params`
363
+ def list_division_orders: (?params: ::Hash[untyped, untyped]) -> ::HTTP::Response
364
+
365
+ # _@param_ `division_order`
366
+ def find_division_order: (String division_order) -> ::HTTP::Response
367
+ end
368
+
369
+ # Division classes module
370
+ # @see https://docs.trefle.io/reference#tag/DivisionClasses
371
+ module DivisionClasses
372
+ # GET /division_classes
373
+ #
374
+ # _@param_ `params`
375
+ def list_division_classes: (::Hash[untyped, untyped] params) -> ::HTTP::Response
376
+
377
+ # _@param_ `division_class`
378
+ def find_division_class: (String division_class) -> ::HTTP::Response
379
+ end
380
+ end
381
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: plants
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Xero
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ description: Gem to interact with Trefle API.
28
+ email:
29
+ - vhector.1337@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - ".ruby-gemset"
37
+ - ".ruby-version"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - README.md
42
+ - Rakefile
43
+ - lib/plants.rb
44
+ - lib/plants/client.rb
45
+ - lib/plants/config.rb
46
+ - lib/plants/log.rb
47
+ - lib/plants/resources.rb
48
+ - lib/plants/resources/corrections.rb
49
+ - lib/plants/resources/distributions.rb
50
+ - lib/plants/resources/division_classes.rb
51
+ - lib/plants/resources/division_orders.rb
52
+ - lib/plants/resources/divisions.rb
53
+ - lib/plants/resources/families.rb
54
+ - lib/plants/resources/genus.rb
55
+ - lib/plants/resources/kingdoms.rb
56
+ - lib/plants/resources/plants.rb
57
+ - lib/plants/resources/species.rb
58
+ - lib/plants/resources/subkingdoms.rb
59
+ - lib/plants/version.rb
60
+ - plants.gemspec
61
+ - sig/plants.rbs
62
+ homepage: https://github.com/one-m1nd/plants
63
+ licenses: []
64
+ metadata:
65
+ homepage_uri: https://github.com/one-m1nd/plants
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.4.10
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Plants API gem.
85
+ test_files: []