hotchoc 0.0.1

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: 712dd4cc4edbc921ba19da7b36c609597ba489f5
4
+ data.tar.gz: f5d5f5eefea75d10a73a2f7f95038039d96056a5
5
+ SHA512:
6
+ metadata.gz: 0bc4281b3606d88dc0c5a7ddd47c7d4a3a60de153938d321a65a57ea5bf277dbbcff93023e6aa24f7e73b01462bdc5b3958b035ceeceb97b552029321e572f8c
7
+ data.tar.gz: 5d864289c2202cb28ae3cf878e111cfd313ad3c93e569b580956faea2d91ddf4e55310c713f867dce344164f64df9589ea27750a437a83689602877f65038b79
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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour -b -f d
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hotchoc-ruby.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthias Siegel
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,43 @@
1
+ # hotchoc-ruby
2
+
3
+ Official Ruby wrapper for the Hotchoc API (in private beta).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'hotchoc'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hotchoc
18
+
19
+ ## Usage
20
+
21
+ ### Rails
22
+
23
+ Add an initializer ```config/initializers/hotchoc.rb``` with your details:
24
+
25
+ Hotchoc.configure do |config|
26
+ config.api_key = 'abcde' # Your API key
27
+ config.site = 'mysite' # Short name of your site
28
+ config.format = :json # Can be :json (default) or :xml
29
+ end
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch
35
+ 3. Commit your changes
36
+ 4. Push to the branch
37
+ 5. Create new Pull Request
38
+
39
+ ## Copyright
40
+
41
+ Copyright (c) 2014 Matthias Siegel. See [LICENSE][] for details.
42
+
43
+ [license]: LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/hotchoc.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'hotchoc/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "hotchoc"
7
+ spec.version = Hotchoc::VERSION
8
+ spec.authors = ["Matthias Siegel"]
9
+ spec.email = ["matthias.siegel@gmail.com"]
10
+ spec.summary = %q{Official Ruby wrapper for the Hotchoc API.}
11
+ spec.description = %q{Official Ruby wrapper for the Hotchoc API.}
12
+ spec.homepage = "https://github.com/choc/hotchoc-ruby"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(spec)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.5"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rspec"
22
+ end
@@ -0,0 +1,26 @@
1
+ module Hotchoc
2
+ class Client
3
+
4
+ #
5
+ # Define the same set of accessors as in the Hotchoc module
6
+ #
7
+ attr_accessor *Configuration::VALID_CONFIG_KEYS
8
+
9
+ def initialize(options = {})
10
+ merged_options = Hotchoc.options.merge(options)
11
+
12
+ #
13
+ # Copy the merged values to this client and ignore those
14
+ # not part of the configuration.
15
+ #
16
+ Configuration::VALID_CONFIG_KEYS.each do |key|
17
+ send("#{key}=", merged_options[key])
18
+ end
19
+ end
20
+
21
+ def user_agent
22
+ @user_agent ||= "Hotchoc gem #{Hotchoc::VERSION}"
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ module Hotchoc
2
+ module Configuration
3
+
4
+ VALID_CONFIG_KEYS = [:api_key, :site, :hotchoc_hostname, :format].freeze
5
+
6
+ DEFAULT_API_KEY = nil
7
+ DEFAULT_SITE = nil
8
+ DEFAULT_HOTCHOC_HOSTNAME = 'hotchoc.dev'
9
+ DEFAULT_FORMAT = :json
10
+
11
+ #
12
+ # Build accessor methods for every config options so we can do this, for example:
13
+ #
14
+ # Hotchoc.format = :xml
15
+ #
16
+ attr_accessor *VALID_CONFIG_KEYS
17
+
18
+ #
19
+ # Make sure we have the default values set when we get 'extended'
20
+ #
21
+ def self.extended(base)
22
+ base.reset
23
+ end
24
+
25
+ def reset
26
+ self.api_key = DEFAULT_API_KEY
27
+ self.site = DEFAULT_SITE
28
+ self.hotchoc_hostname = DEFAULT_HOTCHOC_HOSTNAME
29
+ self.format = DEFAULT_FORMAT
30
+ end
31
+
32
+ def configure
33
+ yield self
34
+ end
35
+
36
+ def options
37
+ Hash[*VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten]
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Hotchoc
2
+ VERSION = "0.0.1"
3
+ end
data/lib/hotchoc.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'hotchoc/configuration'
2
+ require 'hotchoc/client'
3
+ require 'hotchoc/version'
4
+
5
+ module Hotchoc
6
+ extend Configuration
7
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Client' do
4
+
5
+ before do
6
+ @keys = Hotchoc::Configuration::VALID_CONFIG_KEYS
7
+ end
8
+
9
+ describe 'with module configuration' do
10
+
11
+ before do
12
+ Hotchoc.configure do |config|
13
+ @keys.each do |key|
14
+ config.send("#{key}=", key)
15
+ end
16
+ end
17
+ end
18
+
19
+ after do
20
+ Hotchoc.reset
21
+ end
22
+
23
+ it "should inherit module configuration" do
24
+ api = Hotchoc::Client.new
25
+
26
+ @keys.each do |key|
27
+ api.send(key).should == key
28
+ end
29
+ end
30
+
31
+ describe 'with class configuration' do
32
+
33
+ before do
34
+ @config = {
35
+ api_key: 'abc',
36
+ site: 'def',
37
+ hotchoc_hostname: 'ghi',
38
+ format: 'jkl'
39
+ }
40
+ end
41
+
42
+ it 'should override module configuration' do
43
+ api = Hotchoc::Client.new(@config)
44
+
45
+ @keys.each do |key|
46
+ api.send(key).should == @config[key]
47
+ end
48
+ end
49
+
50
+ it 'should override module configuration after' do
51
+ api = Hotchoc::Client.new
52
+
53
+ @config.each do |key, value|
54
+ api.send("#{key}=", value)
55
+ end
56
+
57
+ @keys.each do |key|
58
+ api.send("#{key}").should == @config[key]
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ describe ".user_agent" do
65
+
66
+ it "should return the user agent with the current version" do
67
+ Hotchoc::Client.new.user_agent.should == "Hotchoc gem #{Hotchoc::VERSION}"
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Configuration' do
4
+
5
+ after do
6
+ Hotchoc.reset
7
+ end
8
+
9
+ Hotchoc::Configuration::VALID_CONFIG_KEYS.each do |key|
10
+ describe ".#{key}" do
11
+ it "should return the default #{key}" do
12
+ Hotchoc.send(key).should == Hotchoc::Configuration.const_get("DEFAULT_#{key.upcase}")
13
+ end
14
+ end
15
+ end
16
+
17
+ describe '.configure' do
18
+
19
+ Hotchoc::Configuration::VALID_CONFIG_KEYS.each do |key|
20
+ it "should set the #{key}" do
21
+ Hotchoc.configure do |config|
22
+ config.send("#{key}=", key)
23
+ Hotchoc.send(key).should == key
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc' do
4
+
5
+ it 'should have a version' do
6
+ Hotchoc::VERSION.should_not be_nil
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'hotchoc'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hotchoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthias Siegel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-19 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
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
+ description: Official Ruby wrapper for the Hotchoc API.
56
+ email:
57
+ - matthias.siegel@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.md
66
+ - README.md
67
+ - Rakefile
68
+ - hotchoc.gemspec
69
+ - lib/hotchoc.rb
70
+ - lib/hotchoc/client.rb
71
+ - lib/hotchoc/configuration.rb
72
+ - lib/hotchoc/version.rb
73
+ - spec/hotchoc/client_spec.rb
74
+ - spec/hotchoc/configuration_spec.rb
75
+ - spec/hotchoc/main_spec.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/choc/hotchoc-ruby
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.2.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Official Ruby wrapper for the Hotchoc API.
101
+ test_files:
102
+ - spec/hotchoc/client_spec.rb
103
+ - spec/hotchoc/configuration_spec.rb
104
+ - spec/hotchoc/main_spec.rb
105
+ - spec/spec_helper.rb