cobregratis 0.3.0 → 0.4.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
+ SHA1:
3
+ metadata.gz: fe05cbbbe59c6dd0c7b4c9278ea403d438a3d0c2
4
+ data.tar.gz: a3216e1f8be91800714f9c87c15b8cfdfb722ca2
5
+ SHA512:
6
+ metadata.gz: e22cea9249d2fa2a8394be62eeff6bb8db2f468795da1ff183c230edee49507ce4c5de15506dbe2462d87b4005fa251d98d7e9d818402e1ef113964e1616f43a
7
+ data.tar.gz: e61fb6fbe5ee0a9adf2d4ca4c2377002b551fc7bd35f742846ed3bee4d852808cc7e1cca24e1693907e9bdf4bc9a8493c450c0f474bda6047bfb890a289ccd89
data/.bundle/config CHANGED
@@ -1,2 +1,2 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
1
+ --- {}
2
+
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ cobregratis-ruby
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/Gemfile CHANGED
@@ -1,14 +1,5 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- gem "activeresource", ">= 2.1"
5
- gem "activesupport", ">= 2.1"
1
+ source 'https://rubygems.org'
2
+ ruby '2.1.0'
6
3
 
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "rspec", "~> 2.3.0"
11
- gem "bundler", "~> 1.0.0"
12
- gem "jeweler", "~> 1.5.2"
13
- gem "rcov", ">= 0"
14
- end
4
+ # Specify your gem's dependencies in cobregratis.gemspec
5
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,40 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cobregratis (0.4.0)
5
+ activeresource (~> 4.0)
6
+ activesupport (~> 4.0)
7
+
1
8
  GEM
2
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
3
10
  specs:
4
- activemodel (3.0.5)
5
- activesupport (= 3.0.5)
6
- builder (~> 2.1.2)
7
- i18n (~> 0.4)
8
- activeresource (3.0.5)
9
- activemodel (= 3.0.5)
10
- activesupport (= 3.0.5)
11
- activesupport (3.0.5)
12
- builder (2.1.2)
13
- diff-lcs (1.1.2)
14
- git (1.2.5)
15
- i18n (0.5.0)
16
- jeweler (1.5.2)
17
- bundler (~> 1.0.0)
18
- git (>= 1.2.5)
19
- rake
20
- rake (0.8.7)
21
- rcov (0.9.9)
22
- rspec (2.3.0)
23
- rspec-core (~> 2.3.0)
24
- rspec-expectations (~> 2.3.0)
25
- rspec-mocks (~> 2.3.0)
26
- rspec-core (2.3.1)
27
- rspec-expectations (2.3.0)
28
- diff-lcs (~> 1.1.2)
29
- rspec-mocks (2.3.0)
11
+ activemodel (4.0.2)
12
+ activesupport (= 4.0.2)
13
+ builder (~> 3.1.0)
14
+ activeresource (4.0.0)
15
+ activemodel (~> 4.0)
16
+ activesupport (~> 4.0)
17
+ rails-observers (~> 0.1.1)
18
+ activesupport (4.0.2)
19
+ i18n (~> 0.6, >= 0.6.4)
20
+ minitest (~> 4.2)
21
+ multi_json (~> 1.3)
22
+ thread_safe (~> 0.1)
23
+ tzinfo (~> 0.3.37)
24
+ atomic (1.1.14)
25
+ builder (3.1.4)
26
+ diff-lcs (1.2.5)
27
+ docile (1.1.2)
28
+ i18n (0.6.9)
29
+ minitest (4.7.5)
30
+ multi_json (1.8.4)
31
+ rails-observers (0.1.2)
32
+ activemodel (~> 4.0)
33
+ rake (10.1.1)
34
+ rspec (2.14.1)
35
+ rspec-core (~> 2.14.0)
36
+ rspec-expectations (~> 2.14.0)
37
+ rspec-mocks (~> 2.14.0)
38
+ rspec-core (2.14.7)
39
+ rspec-expectations (2.14.4)
40
+ diff-lcs (>= 1.1.3, < 2.0)
41
+ rspec-mocks (2.14.4)
42
+ simplecov (0.8.2)
43
+ docile (~> 1.1.0)
44
+ multi_json
45
+ simplecov-html (~> 0.8.0)
46
+ simplecov-html (0.8.0)
47
+ thread_safe (0.1.3)
48
+ atomic
49
+ tzinfo (0.3.38)
30
50
 
31
51
  PLATFORMS
32
52
  ruby
33
53
 
34
54
  DEPENDENCIES
35
- activeresource (>= 2.1)
36
- activesupport (>= 2.1)
37
- bundler (~> 1.0.0)
38
- jeweler (~> 1.5.2)
39
- rcov
40
- rspec (~> 2.3.0)
55
+ bundler (= 1.5.2)
56
+ cobregratis!
57
+ rake (= 10.1.1)
58
+ rspec (= 2.14.1)
59
+ simplecov (= 0.8.2)
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Ruby Gem para a API do Cobre Grátis
2
+
3
+ Essa biblioteca é um conjunto de classes para acessar as informações do [Cobre Grátis](http://cobregratis.com.br) através da [API](https://github.com/BielSystems/cobregratis-api).
4
+
5
+ Todas as classes são herdadas do ActiveResouce::Base. Veja a documentação do [ActiveResouce](http://api.rubyonrails.org/classes/ActiveResource/Base.html) para mais informações.
6
+
7
+ ## Instalando
8
+
9
+ gem install cobregratis
10
+
11
+ ### Configurando seu token
12
+
13
+ ```ruby
14
+ require 'rubygems'
15
+ require 'cobregratis'
16
+
17
+ Cobregratis::Base.site = 'https://app.cobregratis.com.br'
18
+ Cobregratis::Base.user = 'seu_token'
19
+ Cobregratis::Base.password = 'X'
20
+ ```
21
+
22
+ Se você está usando essa gem numa aplicação Rails, é recomendado colocar esse código no arquivo `config/initializers/cobregratis.rb`. Veja um exemplo em [examples/config_initializers_cobregratis.rb](https://github.com/BielSystems/cobregratis-ruby/blob/master/examples/config_initializers_cobregratis.rb).
23
+
24
+ ## Uso
25
+
26
+ ```ruby
27
+ # criar um boleto
28
+ @bank_billet = Cobregratis::BankBillet.create({
29
+ :amount => 230.50,
30
+ :expire_at => '2015-07-22',
31
+ :name => 'Rafael Lima',
32
+ })
33
+
34
+ # listar todos os boletos
35
+ @bank_billets = Cobregratis::BankBillet.find(:all)
36
+ @billets.each do |bank_billet|
37
+ puts "Nosso Número: #{@bank_billet.our_number}\n";
38
+ puts "Vencimento: #{@bank_billet.expire_at}\n";
39
+ puts "Valor: #{@bank_billet.amount}\n";
40
+ puts "Sacado: #{@bank_billet.name}\n";
41
+ puts "URL: #{@bank_billet.external_link}\n";
42
+ puts "=================================\n";
43
+ end
44
+ ```
45
+
46
+ Veja um exemplo no arquivo [example.rb](https://github.com/BielSystems/cobregratis-ruby/blob/master/examples/example.rb)
47
+
48
+ ## Licença
49
+
50
+ Esse código é livre para ser usado dentro dos termos da licença [MIT license](http://www.opensource.org/licenses/mit-license.php).
51
+
52
+ ## Bugs, Issues, Agradecimentos, etc
53
+
54
+ Comentários são bem-vindos. Envie seu feedback através do [issue tracker do GitHub](http://github.com/BielSystems/cobregratis-ruby/issues)
55
+
56
+ ## Colaboradores
57
+
58
+ Agradecimento especial para o [Tapajós](http://github.com/tapajos).
59
+
60
+ ## Autor
61
+
62
+ [**Rafael Lima**](http://github.com/rafaelp) trabalhando na [BielSystems](http://bielsystems.com.br)
63
+
64
+ Blog: [http://rafael.adm.br](http://rafael.adm.br)
65
+
66
+ Twitter: [http://twitter.com/rafaelp](http://twitter.com/rafaelp)
67
+
68
+ ### Gostou?
69
+
70
+ [Me recomende Working With Rails](http://workingwithrails.com/recommendation/new/person/14248-rafael-lima)
data/Rakefile CHANGED
@@ -1,31 +1,4 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "cobregratis"
16
- gem.homepage = "http://github.com/rafaelp/cobregratis"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Ruby Wrapper around Cobre Grátis API}
19
- gem.description = "Ruby Wrapper around Cobre Grátis API. More info at: http://cobregratis.com.br/doc/api"
20
- gem.email = "contato@rafael.adm.br"
21
- gem.authors = ["Rafael Lima"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- gem.add_runtime_dependency 'activeresource', '>= 2.1'
25
- gem.add_runtime_dependency 'activesupport', '>= 2.1'
26
- gem.add_development_dependency 'rspec', '~> 2.3.0'
27
- end
28
- Jeweler::RubygemsDotOrgTasks.new
1
+ require "bundler/gem_tasks"
29
2
 
30
3
  require 'rspec/core'
31
4
  require 'rspec/core/rake_task'
@@ -38,14 +11,4 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
38
11
  spec.rcov = true
39
12
  end
40
13
 
41
- task :default => :spec
42
-
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
-
47
- rdoc.rdoc_dir = 'rdoc'
48
- rdoc.title = "cobregratis #{version}"
49
- rdoc.rdoc_files.include('README*')
50
- rdoc.rdoc_files.include('lib/**/*.rb')
51
- end
14
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cobregratis/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cobregratis"
8
+ spec.version = Cobregratis::VERSION
9
+ spec.authors = ["Rafael Lima"]
10
+ spec.email = "contato@rafael.adm.br"
11
+ spec.description = "Ruby Wrapper around Cobre Gr\u{e1}tis API. More info at: http://cobregratispec.com.br/doc/api"
12
+ spec.summary = "Ruby Wrapper around Cobre Gr\u{e1}tis API"
13
+ spec.homepage = "http://github.com/BielSystems/cobregratis-ruby"
14
+ spec.licenses = ["MIT"]
15
+ spec.date = "2014-01-25"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency 'activeresource', "~> 4.0"
23
+ spec.add_runtime_dependency 'activesupport', "~> 4.0"
24
+ spec.add_development_dependency "rake", "10.1.1"
25
+ spec.add_development_dependency 'rspec', "2.14.1"
26
+ spec.add_development_dependency 'bundler', "1.5.2"
27
+ spec.add_development_dependency 'simplecov', "0.8.2"
28
+ end
29
+
@@ -1,13 +1,10 @@
1
1
  if Rails.env != 'test' then
2
- Cobregratis::Base.site = 'https://example.com.i'
2
+ Cobregratis::Base.site = 'https://app.cobregratis.com.br'
3
3
  # For backward compatability
4
4
  if Cobregratis::Base.respond_to? :user
5
- Cobregratis::Base.user = 'my_fancy_username'
6
- Cobregratis::Base.password = 'my_fancy_password'
7
- else
8
- Cobregratis::Base.site = 'https://my_fancy_username:my_fancy_password@example.com.i'
5
+ Cobregratis::Base.user = 'my_token'
6
+ Cobregratis::Base.password = 'X'
7
+ else
8
+ Cobregratis::Base.site = 'https://my_token:X@app.cobregratis.com.br'
9
9
  end
10
- # The cache store can be anything that ActiveSupport can handle
11
- Cobregratis::Base.connection.cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store
12
- Cobregratis::Base.connection.store_options = { :expires_in => 60.seconds }
13
10
  end
@@ -0,0 +1,24 @@
1
+ require 'lib/cobregratis'
2
+ require 'pp'
3
+
4
+ Cobregratis::Base.site = 'https://app.cobregratis.com.br'
5
+ Cobregratis::Base.user = 'ddxm00pJnGhrYJhyypUgpwqkbvKMASEznqRM2MANv6nqz08APfWxdurtUJoz'
6
+ Cobregratis::Base.password = 'X'
7
+
8
+ @bank_billet = Cobregratis::BankBillet.create({
9
+ :amount => 230.50,
10
+ :expire_at => '2015-07-22',
11
+ :name => 'Rafael Lima',
12
+ })
13
+
14
+ sleep(1)
15
+ @billets = Cobregratis::BankBillet.find(:all)
16
+
17
+ @billets.each do |bank_billet|
18
+ puts "Nosso Número: #{@bank_billet.our_number}\n";
19
+ puts "Vencimento: #{@bank_billet.expire_at}\n";
20
+ puts "Valor: #{@bank_billet.amount}\n";
21
+ puts "Sacado: #{@bank_billet.name}\n";
22
+ puts "URL: #{@bank_billet.external_link}\n";
23
+ puts "=================================\n";
24
+ end
@@ -1,8 +1,5 @@
1
- require File.dirname(__FILE__) + '/../cachable'
2
-
3
1
  module Cobregratis
4
2
  class Base < ActiveResource::Base
5
3
  self.site = "https://app.cobregratis.com.br"
6
- include ::Cachable
7
4
  end
8
5
  end
@@ -0,0 +1,3 @@
1
+ module Cobregratis
2
+ VERSION = "0.4.0"
3
+ end
data/lib/cobregratis.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  require 'active_resource'
2
- $:.unshift(File.dirname(__FILE__))
2
+ require "cobregratis/version"
3
3
 
4
- require 'cobregratis/base'
5
- require 'cobregratis/bank_billet_account'
6
- require 'cobregratis/bank_billet'
7
- require 'cobregratis/service'
4
+ module Cobregratis
5
+ require 'cobregratis/base'
6
+ require 'cobregratis/bank_billet_account'
7
+ require 'cobregratis/bank_billet'
8
+ require 'cobregratis/service'
9
+ end
10
+
11
+ def gem_path
12
+ Gem::Specification.find_by_name('jumpup-heroku').full_gem_path
13
+ end
metadata CHANGED
@@ -1,236 +1,160 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cobregratis
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Rafael Lima
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-05-20 00:00:00 -03:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :runtime
11
+ date: 2014-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
24
14
  name: activeresource
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 1
31
- segments:
32
- - 2
33
- - 1
34
- version: "2.1"
35
- requirement: *id001
36
- - !ruby/object:Gem::Dependency
37
- prerelease: false
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
38
20
  type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
39
28
  name: activesupport
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 1
46
- segments:
47
- - 2
48
- - 1
49
- version: "2.1"
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
52
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 10.1.1
53
48
  type: :development
54
- name: rspec
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 2
63
- - 3
64
- - 0
65
- version: 2.3.0
66
- requirement: *id003
67
- - !ruby/object:Gem::Dependency
68
49
  prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 10.1.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
69
62
  type: :development
70
- name: bundler
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 23
77
- segments:
78
- - 1
79
- - 0
80
- - 0
81
- version: 1.0.0
82
- requirement: *id004
83
- - !ruby/object:Gem::Dependency
84
63
  prerelease: false
85
- type: :development
86
- name: jeweler
87
- version_requirements: &id005 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ~>
91
- - !ruby/object:Gem::Version
92
- hash: 7
93
- segments:
94
- - 1
95
- - 5
96
- - 2
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
97
75
  version: 1.5.2
98
- requirement: *id005
99
- - !ruby/object:Gem::Dependency
100
- prerelease: false
101
76
  type: :development
102
- name: rcov
103
- version_requirements: &id006 !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
- requirement: *id006
113
- - !ruby/object:Gem::Dependency
114
- prerelease: false
115
- type: :runtime
116
- name: activeresource
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 1
123
- segments:
124
- - 2
125
- - 1
126
- version: "2.1"
127
- requirement: *id007
128
- - !ruby/object:Gem::Dependency
129
- prerelease: false
130
- type: :runtime
131
- name: activesupport
132
- version_requirements: &id008 !ruby/object:Gem::Requirement
133
- none: false
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- hash: 1
138
- segments:
139
- - 2
140
- - 1
141
- version: "2.1"
142
- requirement: *id008
143
- - !ruby/object:Gem::Dependency
144
77
  prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.2
145
90
  type: :development
146
- name: rspec
147
- version_requirements: &id009 !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
150
- - - ~>
151
- - !ruby/object:Gem::Version
152
- hash: 3
153
- segments:
154
- - 2
155
- - 3
156
- - 0
157
- version: 2.3.0
158
- requirement: *id009
159
- description: "Ruby Wrapper around Cobre Gr\xC3\xA1tis API. More info at: http://cobregratis.com.br/doc/api"
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.2
97
+ description: 'Ruby Wrapper around Cobre Grátis API. More info at: http://cobregratispec.com.br/doc/api'
160
98
  email: contato@rafael.adm.br
161
99
  executables: []
162
-
163
100
  extensions: []
164
-
165
- extra_rdoc_files:
166
- - LICENSE
167
- - README.mkdn
168
- files:
169
- - .bundle/config
170
- - .document
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".bundle/config"
104
+ - ".document"
105
+ - ".gitignore"
106
+ - ".ruby-gemset"
107
+ - ".ruby-version"
171
108
  - Gemfile
172
109
  - Gemfile.lock
173
110
  - LICENSE
174
- - README.mkdn
111
+ - README.md
175
112
  - Rakefile
176
- - VERSION
177
113
  - autotest/discover.rb
114
+ - cobregratis.gemspec
178
115
  - examples/config_initializers_cobregratis.rb
179
- - examples/sample.rb
116
+ - examples/example.rb
180
117
  - init.rb
181
- - lib/cachable.rb
182
118
  - lib/cobregratis.rb
183
119
  - lib/cobregratis/bank_billet.rb
184
120
  - lib/cobregratis/bank_billet_account.rb
185
121
  - lib/cobregratis/base.rb
186
122
  - lib/cobregratis/service.rb
187
- - spec/cachable_spec.rb
123
+ - lib/cobregratis/version.rb
188
124
  - spec/cobregratis/bank_billet_account_spec.rb
189
125
  - spec/cobregratis/bank_billet_spec.rb
190
126
  - spec/cobregratis/base_spec.rb
191
127
  - spec/cobregratis/service_spec.rb
192
128
  - spec/spec.opts
193
129
  - spec/spec_helper.rb
194
- has_rdoc: true
195
- homepage: http://github.com/rafaelp/cobregratis
196
- licenses:
130
+ homepage: http://github.com/BielSystems/cobregratis-ruby
131
+ licenses:
197
132
  - MIT
133
+ metadata: {}
198
134
  post_install_message:
199
135
  rdoc_options: []
200
-
201
- require_paths:
136
+ require_paths:
202
137
  - lib
203
- required_ruby_version: !ruby/object:Gem::Requirement
204
- none: false
205
- requirements:
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
206
140
  - - ">="
207
- - !ruby/object:Gem::Version
208
- hash: 3
209
- segments:
210
- - 0
211
- version: "0"
212
- required_rubygems_version: !ruby/object:Gem::Requirement
213
- none: false
214
- requirements:
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
215
145
  - - ">="
216
- - !ruby/object:Gem::Version
217
- hash: 3
218
- segments:
219
- - 0
220
- version: "0"
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
221
148
  requirements: []
222
-
223
149
  rubyforge_project:
224
- rubygems_version: 1.3.7
150
+ rubygems_version: 2.2.0.rc.1
225
151
  signing_key:
226
- specification_version: 3
227
- summary: "Ruby Wrapper around Cobre Gr\xC3\xA1tis API"
228
- test_files:
229
- - examples/config_initializers_cobregratis.rb
230
- - examples/sample.rb
231
- - spec/cachable_spec.rb
152
+ specification_version: 4
153
+ summary: Ruby Wrapper around Cobre Grátis API
154
+ test_files:
232
155
  - spec/cobregratis/bank_billet_account_spec.rb
233
156
  - spec/cobregratis/bank_billet_spec.rb
234
157
  - spec/cobregratis/base_spec.rb
235
158
  - spec/cobregratis/service_spec.rb
159
+ - spec/spec.opts
236
160
  - spec/spec_helper.rb
data/README.mkdn DELETED
@@ -1,81 +0,0 @@
1
- # Cobregratis
2
-
3
- ## What is it?
4
-
5
- This gem provides a set of classes to access information on [Cobre Grátis][cg] via the published [API][api].
6
-
7
- All these classes are inherited from ActiveResouce::Base. Refer to the [ActiveResouce][ar] documentation for more information.
8
-
9
- ## Installing
10
-
11
- gem install cobregratis
12
-
13
- ### Dependencies (see the Rakefile or run <code>rake check_dependencies</code>)
14
-
15
- ### Documentation
16
-
17
- I'm on [rdoc.info][rdoc]
18
-
19
- ### Configure your key
20
-
21
- require 'rubygems'
22
- require 'cobregratis'
23
-
24
- Cobregratis::Base.site = 'https://app.cobregratis.com.br'
25
- Cobregratis::Base.user = 'your_token'
26
- Cobregratis::Base.password = 'X'
27
-
28
- and, if you want [caching][c]:
29
-
30
- Cobregratis::Base.connection.cache_store= <your normal ActiveSupport::Caching options>
31
-
32
- If you are using this in a Rails application, putting this code in a config/initializers/cobregratis.rb
33
- file is recommended. See config_initializers_cobregratis.rb in the examples/ directory.
34
-
35
- ## Usage
36
-
37
- @bank_billets = Cobregratis::BankBillet.find(:all)
38
- @bank_billet_accounts = Cobregratis::BankBilletAccount.find(:all)
39
- @services = Cobregratis::Service.find(:all)
40
-
41
- ## License
42
-
43
- This code is free to be used under the terms of the [MIT license][mit].
44
-
45
- ## Bugs, Issues, Kudos and Catcalls
46
-
47
- Comments are welcome. Send your feedback through the [issue tracker on GitHub][i]
48
-
49
- ## Contributors
50
-
51
- Special thanks to:
52
-
53
- ### **Tapajós**
54
-
55
- Github: [http://github.com/tapajos](http://github.com/tapajos)
56
-
57
- ## Author
58
-
59
- ### **Rafael Lima**
60
-
61
- Working at [BielSystems](http://bielsystems.com.br)
62
-
63
- Blog: [http://rafael.adm.br](http://rafael.adm.br)
64
-
65
- Podcast: [http://rafael.adm.br/voltandopracasa](http://rafael.adm.br/voltandopracasa)
66
-
67
- Github: [http://github.com/rafaelp](http://github.com/rafaelp)
68
-
69
- Twitter: [http://twitter.com/rafaelp](http://twitter.com/rafaelp)
70
-
71
- ### Did you like?
72
-
73
- [Recommend me at Working With Rails](http://workingwithrails.com/recommendation/new/person/14248-rafael-lima)
74
-
75
- [api]: http://app.cobregratis.com.br/api
76
- [ar]: http://api.rubyonrails.org/classes/ActiveResource/Base.html
77
- [c]: http://api.rubyonrails.org/classes/ActiveSupport/Cache
78
- [cg]: http://cobregratis.com.br/
79
- [i]: http://github.com/rafaelp/cobregratis/issues
80
- [mit]:http://www.opensource.org/licenses/mit-license.php
81
- [rdoc]: http://rdoc.info/projects/rafaelp/cobregratis
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
data/examples/sample.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'cobregratis'
2
- require 'pp'
3
-
4
- Cobregratis::Base.site = 'https://app.cobregratis.com.br'
5
- Cobregratis::Base.user = 'login'
6
- Cobregratis::Base.password = 'xxx'
7
- Cobregratis::Base.connection.cache_store = :memory_store
8
-
9
- @billets = Cobregratis::Billet.find(:all)
10
-
11
- pp @billets
data/lib/cachable.rb DELETED
@@ -1,83 +0,0 @@
1
- # Caching is a way to speed up slow ActiveResource queries by keeping the result of
2
- # a request around to be reused by subsequent requests.
3
- #
4
- # Caching is turned OFF by default.
5
- #
6
- # == Usage
7
- #
8
- # require 'cachable'
9
- #
10
- # module CachedResource < ActiveResource::Base
11
- # include ::Cachable
12
- # end
13
- #
14
- #
15
- # == Caching stores
16
- #
17
- # All the caching stores from ActiveSupport::Cache are available
18
- # as backends for caching. See the Rails rdoc for more information on
19
- # these stores
20
- #
21
- # === Configuration examples ('off' is the default):
22
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
23
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :file_store, "/path/to/cache/directory"
24
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :drb_store, "druby://localhost:9192"
25
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"
26
- # CachedResource.connection.cache_store = MyOwnStore.new("parameter")
27
- #
28
- # === If you are using a store that has write options, you can set them
29
- # CachedResource.connection.cache_options = { :expires_in => 60.seconds }
30
- #
31
- # Note: To ensure that caching is turned off, set CachedResource.connection.cache_store = nil
32
- #
33
- # FYI: You can use this with *any* active resource class, not just Cobregratis.
34
-
35
- module Cachable
36
- def self.included(base)
37
- ActiveResource::Connection.class_eval do
38
- def cache_store
39
- @cache_store ||= nil
40
- end
41
-
42
- def cache_store=(store)
43
- @cache_store = store
44
- end
45
-
46
- def cache_options
47
- @cache_options ||= {}
48
- end
49
- alias :store_options :cache_options
50
-
51
- def cache_options=(options)
52
- @cache_options = options
53
- end
54
- alias :store_options= :cache_options=
55
-
56
- def is_caching?
57
- !@cache_store.nil?
58
- end
59
-
60
- def get_with_cache(path, headers = {})
61
- return get_without_cache(path, headers) unless is_caching?
62
- cache_store.fetch(cache_key(path), cache_options) {get_without_cache(path, headers)}
63
- end
64
- alias_method_chain :get, :cache
65
-
66
- def put_with_cache(path, body = '', headers = {})
67
- cache_store.delete(cache_key(path)) if is_caching?
68
- put_without_cache(path, body, headers)
69
- end
70
- alias_method_chain :put, :cache
71
-
72
- def delete_with_cache(path, headers = {})
73
- cache_store.delete(cache_key(path)) if is_caching?
74
- delete_without_cache(path, headers)
75
- end
76
- alias_method_chain :delete, :cache
77
-
78
- def cache_key(*args)
79
- args.join(':')
80
- end
81
- end
82
- end
83
- end
@@ -1,122 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class CachedResource < ActiveResource::Base
4
- include ::Cachable
5
- end
6
-
7
- describe CachedResource, "class configuration" do
8
- before(:each) do
9
- CachedResource.site = 'http://example.com.i:3000'
10
- end
11
-
12
- it "should tell us if caching is active" do
13
- CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
14
- CachedResource.connection.is_caching?.should == true
15
- end
16
-
17
- it "should tell us if caching is not active" do
18
- CachedResource.connection.cache_store = nil
19
- CachedResource.connection.is_caching?.should == false
20
- end
21
- end
22
-
23
- describe CachedResource do
24
- before(:all) do
25
- CachedResource.site = 'http://example.com.i:3000'
26
- end
27
-
28
- after(:all) do
29
- CachedResource.connection.cache_store = :none
30
- end
31
-
32
- before(:each) do
33
- @thing = CachedResource.new(:id => 1)
34
- @key = :key
35
- CachedResource.connection.stub!(:cache_key).and_return(@key)
36
- end
37
-
38
- context "when cache is configured" do
39
- before(:all) do
40
- CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
41
- end
42
-
43
- context "when a cached response is available" do
44
- before(:each) do
45
- CachedResource.connection.cache_store.write(@key, @thing.attributes)
46
- end
47
-
48
- it "should NOT make a request to the RESTful server" do
49
- CachedResource.connection.should_not_receive(:get_without_cache)
50
- CachedResource.find(1)
51
- end
52
-
53
- it "should read from the cache" do
54
- CachedResource.find(1).should == @thing
55
- end
56
-
57
- it "should delete from the cache when an object is DELETEd" do
58
- CachedResource.connection.should_receive(:delete_without_cache)
59
- CachedResource.delete(1)
60
- CachedResource.connection.cache_store.read(@key).should == nil
61
- end
62
-
63
- it "should delete from the cache when an object is modified" do
64
- thing = CachedResource.find(1)
65
- thing.stub(:load_attributes_from_response).and_return(@thing.attributes)
66
- CachedResource.connection.should_receive(:put_without_cache)
67
- thing.save
68
- CachedResource.connection.cache_store.read(@key).should == nil
69
- end
70
- end
71
-
72
- context "when a cached response is NOT available" do
73
- before(:each) do
74
- CachedResource.connection.cache_store.delete(@key)
75
- end
76
-
77
- it "SHOULD perform an ActiveResource request" do
78
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
79
- CachedResource.find(1)
80
- end
81
-
82
- it "should cache the response using the caching key" do
83
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
84
- CachedResource.find(1)
85
- CachedResource.connection.cache_store.read(@key).should == @thing.attributes
86
- end
87
- end
88
- end
89
-
90
- context "when cache is not configured" do
91
- before(:all) do
92
- CachedResource.connection.cache_store = nil
93
- end
94
-
95
- it "SHOULD perform an ActiveResource request" do
96
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
97
- CachedResource.find(1)
98
- end
99
-
100
- it "should not raise exception finding object" do
101
- lambda {
102
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
103
- CachedResource.find(1)
104
- }.should_not raise_exception
105
- end
106
-
107
- it "should not raise exception when an object is DELETEd" do
108
- lambda {
109
- CachedResource.connection.should_receive(:delete_without_cache)
110
- CachedResource.delete(1)
111
- }.should_not raise_exception
112
- end
113
-
114
- it "should not raise exception when an object is modified" do
115
- lambda {
116
- @thing.stub(:load_attributes_from_response).and_return(@thing.attributes)
117
- CachedResource.connection.should_receive(:put_without_cache)
118
- @thing.save
119
- }.should_not raise_exception
120
- end
121
- end
122
- end