octonore 0.0.2

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: 4c2a77f05a337906a4f02bdb8980953c05f488aa
4
+ data.tar.gz: 09cb7615f610c19e264e2f396fcd01c970ce8454
5
+ SHA512:
6
+ metadata.gz: 0daa7a05c87557fa64ba1e8b61be8adfaa9c0330d4536453a5cb3938383291cbc0c0b1b12c46200dec2970b88224b35fc86513e546ff3dce549f3ac73ac9ed11
7
+ data.tar.gz: 2771e998fbc5949d4856661afe7ae3cbbc60c8b46f999ab36d66a766e38fb3d44045624e1822495a5731020bda2d16740a6b8da0b304ee48cf7cd26c1a3c5b4a
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ############
2
+ # Ruby #
3
+ ############
4
+
5
+ *.gem
6
+ *.rbc
7
+ .bundle
8
+ .config
9
+ coverage
10
+ InstalledFiles
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ # YARD artifacts
20
+ .yardoc
21
+ _yardoc
22
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'httparty'
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'webmock'
8
+ gem 'vcr'
9
+ gem 'rake'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.4)
5
+ crack (0.3.2)
6
+ diff-lcs (1.2.4)
7
+ httparty (0.11.0)
8
+ multi_json (~> 1.0)
9
+ multi_xml (>= 0.5.2)
10
+ multi_json (1.7.3)
11
+ multi_xml (0.5.3)
12
+ rake (10.0.4)
13
+ rspec (2.13.0)
14
+ rspec-core (~> 2.13.0)
15
+ rspec-expectations (~> 2.13.0)
16
+ rspec-mocks (~> 2.13.0)
17
+ rspec-core (2.13.1)
18
+ rspec-expectations (2.13.0)
19
+ diff-lcs (>= 1.1.3, < 2.0)
20
+ rspec-mocks (2.13.1)
21
+ vcr (2.5.0)
22
+ webmock (1.11.0)
23
+ addressable (>= 2.2.7)
24
+ crack (>= 0.3.2)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ httparty
31
+ rake
32
+ rspec
33
+ vcr
34
+ webmock
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Zachary Latta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ Octonore
2
+ ========
3
+
4
+ An octolicious wrapper around the [Gitignore templates API](http://developer.github.com/v3/gitignore/).
5
+
6
+ $ gem install octonore
7
+
8
+
9
+ Usage
10
+ -----
11
+
12
+ To get a gitignore template you first need to instantiate it.
13
+
14
+ >> c_template = Octonore::Template.new('C')
15
+ => #<Octonore::Template:0x007fe5f401a1d0 @name="C">
16
+
17
+ To get a hash of its name and source code, call its `data` method.
18
+
19
+ >> c_template.data
20
+ => #<HTTParty::Response:0x7fe5f50adad8 parsed_response={"name"=>"C", "source"=>"# Object fi…
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:test)
4
+
5
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
data/lib/octonore.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'httparty'
2
+
3
+ Dir[File.dirname(__FILE__) + '/octonore/*.rb'].each do |file|
4
+ require file
5
+ end
@@ -0,0 +1,55 @@
1
+ module Octonore
2
+
3
+ # A gitignore template. Templates consist of a name and source.
4
+ class Template
5
+
6
+ attr_accessor :name
7
+
8
+ include HTTParty
9
+
10
+ USER_AGENT = "octocore/#{VERSION}"
11
+
12
+ base_uri 'https://api.github.com/gitignore'
13
+
14
+ # Create a new template!
15
+ #
16
+ # Example:
17
+ # c_template = Octonore::Template.new('C')
18
+ # java_template = Octonore::Template.new('Java')
19
+ #
20
+ # Arguments:
21
+ # name: (String)
22
+
23
+ def initialize(name)
24
+ self.name = name
25
+ end
26
+
27
+ # Get a Hash of the template's name and source.
28
+ #
29
+ # Example:
30
+ # >> c_template.data["name"]
31
+ # => C
32
+ #
33
+ # >> c_template.data["source"]
34
+ # => # Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects
35
+ # (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n
36
+ # *.exe\n*.out\n*.app\n
37
+
38
+ def data(force = false)
39
+ force ? @data = get_data : @data ||= get_data
40
+ end
41
+
42
+
43
+ private
44
+
45
+ def get_data
46
+ self.class.get "/templates/#{self.name}", headers: headers
47
+ end
48
+
49
+ def headers
50
+ {"User-Agent" => USER_AGENT}
51
+ end
52
+
53
+ end
54
+
55
+ end
data/octonore.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'octonore'
3
+ s.version = '0.0.2'
4
+ s.date = '2013-05-23'
5
+ s.summary = "Wrapper around the Github gitignore template API."
6
+ s.description = "An octolicious wrapper around the Github gitignore template
7
+ API."
8
+ s.license = 'MIT'
9
+
10
+ s.authors = ["Zach Latta"]
11
+ s.email = 'zchlatta@gmail.com'
12
+ s.homepage = 'http://rubygems.org/gems/octonore'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f|
17
+ File.basename(f)
18
+ }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,82 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/gitignore/gitignore/templates/C
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 403
13
+ message: Forbidden
14
+ headers:
15
+ Server:
16
+ - GitHub.com
17
+ Date:
18
+ - Thu, 23 May 2013 08:52:40 GMT
19
+ Content-Type:
20
+ - application/octet-stream
21
+ Content-Length:
22
+ - '107'
23
+ Connection:
24
+ - keep-alive
25
+ body:
26
+ encoding: UTF-8
27
+ string: '{"message":"Missing or invalid User Agent string. See http://developer.github.com/v3/#user-agent-required"}'
28
+ http_version:
29
+ recorded_at: Thu, 23 May 2013 08:52:40 GMT
30
+ - request:
31
+ method: get
32
+ uri: https://api.github.com/gitignore/templates/C
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ User-Agent:
38
+ - octocore/0.11.0
39
+ response:
40
+ status:
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ Server:
45
+ - GitHub.com
46
+ Date:
47
+ - Thu, 23 May 2013 08:52:40 GMT
48
+ Content-Type:
49
+ - application/json; charset=utf-8
50
+ Connection:
51
+ - keep-alive
52
+ Status:
53
+ - 200 OK
54
+ X-Ratelimit-Limit:
55
+ - '60'
56
+ X-Ratelimit-Remaining:
57
+ - '51'
58
+ X-Github-Media-Type:
59
+ - github.beta; format=json
60
+ X-Content-Type-Options:
61
+ - nosniff
62
+ Content-Length:
63
+ - '180'
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Access-Control-Expose-Headers:
67
+ - ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-OAuth-Scopes, X-Accepted-OAuth-Scopes
68
+ Access-Control-Allow-Origin:
69
+ - '*'
70
+ Etag:
71
+ - '"547a43504d718cb7bc42ed51aae7f643"'
72
+ Cache-Control:
73
+ - max-age=0, private, must-revalidate
74
+ Vary:
75
+ - Accept-Encoding
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"name":"C","source":"# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n#
79
+ Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n"}'
80
+ http_version:
81
+ recorded_at: Thu, 23 May 2013 08:52:40 GMT
82
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,70 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe Octonore::Template do
4
+
5
+ describe "default attributes" do
6
+
7
+ it "should have httparty methods" do
8
+ Octonore::Template.should include(HTTParty)
9
+ end
10
+
11
+ it "should have the base url set to the Github API gitignore endpoint" do
12
+ Octonore::Template.base_uri.should eq('https://api.github.com/gitignore')
13
+ end
14
+
15
+ end
16
+
17
+ describe "default instance attributes" do
18
+
19
+ let(:template) { Octonore::Template.new('C') }
20
+
21
+ it "should have a name attribute" do
22
+ template.should respond_to :name
23
+ end
24
+
25
+ it "should have the right name" do
26
+ template.name.should eq('C')
27
+ end
28
+
29
+ end
30
+
31
+ describe "GET template" do
32
+
33
+ let(:template) { Octonore::Template.new('C') }
34
+
35
+ before { VCR.insert_cassette 'template', :record => :new_episodes }
36
+
37
+ after { VCR.eject_cassette }
38
+
39
+ it "should have a data method" do
40
+ template.should respond_to :data
41
+ end
42
+
43
+ it "should parse the api response from JSON to Hash" do
44
+ template.data.should be_instance_of Hash
45
+ end
46
+
47
+ it "should get the right data" do
48
+ template.data["name"].should eq('C')
49
+ end
50
+
51
+ describe "caching" do
52
+
53
+ before do
54
+ template.data
55
+ stub_request(:any, /api.github.com/).to_timeout
56
+ end
57
+
58
+ it "must cache the data" do
59
+ template.data.should be_instance_of Hash
60
+ end
61
+
62
+ it "must refresh the data if forced" do
63
+ lambda { template.data(true) }.should raise_error Timeout::Error
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../lib/octonore'
2
+
3
+ require 'webmock/rspec'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/fixtures/octonore_cassettes'
8
+ c.hook_into :webmock
9
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octonore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Zach Latta
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ An octolicious wrapper around the Github gitignore template
15
+ API.
16
+ email: zchlatta@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - VERSION
28
+ - lib/octonore.rb
29
+ - lib/octonore/template.rb
30
+ - octonore.gemspec
31
+ - spec/fixtures/octonore_cassettes/template.yml
32
+ - spec/lib/octonore/template_spec.rb
33
+ - spec/spec_helper.rb
34
+ homepage: http://rubygems.org/gems/octonore
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.0.3
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Wrapper around the Github gitignore template API.
58
+ test_files:
59
+ - spec/fixtures/octonore_cassettes/template.yml
60
+ - spec/lib/octonore/template_spec.rb
61
+ - spec/spec_helper.rb