noops_hexbot 0.1.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
+ SHA256:
3
+ metadata.gz: 53dc6dfd9467d796e8d3ce2ce1e0cb4c5da0478fe08aa304b9d3a9da75847edd
4
+ data.tar.gz: 6ee853e673fcf516b99b607d42cdd7d05a1c36b0d84100617d046b5625323c90
5
+ SHA512:
6
+ metadata.gz: f94e9f89da2e200ec670d0021ead5382b070ace90262ef47c9aba6d84bffaef4c147ea84b6b0172adf64aefa839a35de499e909e69fabcc72e94b58c06e102a8
7
+ data.tar.gz: 6df360d108d8cdea0d7eef6564e8c32a577cbcbd1977d0771596c8249fb6596dd9032cbd9d6c93ccdd7dcb20ddaf4e50d34de02077ea328bdc05995b2fb1f317
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in noops_hexbot.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ noops_hexbot (0.1.0)
5
+ httparty (~> 0.13.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ httparty (0.13.7)
11
+ json (~> 1.8)
12
+ multi_xml (>= 0.5.2)
13
+ json (1.8.6)
14
+ minitest (5.14.0)
15
+ multi_xml (0.6.0)
16
+ rake (10.5.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ bundler (~> 2.0)
23
+ minitest (~> 5.0)
24
+ noops_hexbot!
25
+ rake (~> 10.0)
26
+
27
+ BUNDLED WITH
28
+ 2.0.1
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # NoopsHexbot
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/noops_hexbot`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'noops_hexbot'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install noops_hexbot
22
+
23
+ ## Examples
24
+
25
+ ```ruby
26
+ # Set up a client
27
+ client = NoopsHexbot::Client.new
28
+
29
+ #Call methods on the client, there are only 3 methods:
30
+ client.colour # Returns a single hexcode
31
+ client.colours(3) # Returns an array of hexcodes (Max 1000)
32
+ client.colours_with_seeds(10, ["FFFFFF", "000000"]) # Returns an array of hexcodes. Hexcodes should not have the #. Hexcodes will be a mix of a random combination of two of the seeds. Invalid hexcode will return an error.
33
+ # All of these methods can also be called by replacing the colour with color.
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/raidzklart/noops_hexbot.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "noops_hexbot"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,50 @@
1
+ require "./lib/noops_hexbot/version.rb"
2
+ require "httparty"
3
+
4
+ module NoopsHexbot
5
+ class Error < StandardError; end
6
+ class Client
7
+ include HTTParty
8
+ def initialize
9
+ @base_uri = "https://api.noopschallenge.com"
10
+ end
11
+
12
+ def colour
13
+ parse_response(HTTParty.get "#{@base_uri}/hexbot").first["value"]
14
+ end
15
+
16
+ def color
17
+ colour
18
+ end
19
+
20
+ def colours(count)
21
+ check_count(count)
22
+ colours = []
23
+ parse_response(HTTParty.get "#{@base_uri}/hexbot?count=#{count}").each { |i| colours <<i["value"] }
24
+ colours
25
+ end
26
+
27
+ def colors(count)
28
+ colours(count)
29
+ end
30
+
31
+ def colours_with_seeds(count, seeds)
32
+ check_count(count)
33
+ colours = []
34
+ parse_response(HTTParty.get "#{@base_uri}/hexbot?count=#{count}&seed=#{seeds.join(',')}").each { |i| colours << i["value"] }
35
+ colours
36
+ end
37
+
38
+ def colors_with_seeds(count, seeds)
39
+ colours_with_seeds(count, seeds)
40
+ end
41
+
42
+ private
43
+ def parse_response(response)
44
+ response.parsed_response["colors"]
45
+ end
46
+ def check_count(count)
47
+ raise "Count must be between 1 and 1000" if count > 1001
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module NoopsHexbot
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "noops_hexbot/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "noops_hexbot"
8
+ spec.version = NoopsHexbot::VERSION
9
+ spec.authors = ["Thomas Christopher"]
10
+ spec.email = ["thomas.j.christopher@gmail.com"]
11
+
12
+ spec.summary = %q{A Ruby Wrapper for Github's Hexbot Noops Challenge}
13
+ spec.homepage = "https://github.com/raidzklart/noops_hexbot"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/raidzklart/noops_hexbot"
20
+ spec.metadata["changelog_uri"] = "https://github.com/raidzklart/noops_hexbot"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 2.0"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "minitest", "~> 5.0"
38
+
39
+ spec.add_dependency "httparty", "~> 0.13.7"
40
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noops_hexbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Christopher
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-29 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.13.7
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.13.7
69
+ description:
70
+ email:
71
+ - thomas.j.christopher@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - lib/noops_hexbot.rb
85
+ - lib/noops_hexbot/version.rb
86
+ - noops_hexbot.gemspec
87
+ homepage: https://github.com/raidzklart/noops_hexbot
88
+ licenses: []
89
+ metadata:
90
+ homepage_uri: https://github.com/raidzklart/noops_hexbot
91
+ source_code_uri: https://github.com/raidzklart/noops_hexbot
92
+ changelog_uri: https://github.com/raidzklart/noops_hexbot
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.0.3
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: A Ruby Wrapper for Github's Hexbot Noops Challenge
112
+ test_files: []