confiture 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ lib/**/*.rb
2
+ README.rdoc
3
+ CHANGELOG.rdoc
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ html
2
+ pkg
3
+ *.gem
4
+ .DS_Store
5
+ .bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@confiture --create
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ script: "bundle exec rake"
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - rbx
7
+ - rbx-2.0
8
+ - ree
9
+ - ruby-head
10
+ - jruby
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ == 0.0.1
2
+
3
+ * initial version
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ confiture (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rake (0.9.2.2)
11
+ rspec (2.7.0)
12
+ rspec-core (~> 2.7.0)
13
+ rspec-expectations (~> 2.7.0)
14
+ rspec-mocks (~> 2.7.0)
15
+ rspec-core (2.7.1)
16
+ rspec-expectations (2.7.0)
17
+ diff-lcs (~> 1.1.2)
18
+ rspec-mocks (2.7.0)
19
+
20
+ PLATFORMS
21
+ java
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ confiture!
26
+ rake (~> 0.9.2.2)
27
+ rspec (~> 2.7.0)
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ == Infos
2
+
3
+ Status: http://stillmaintained.com/phoet/asin.png
4
+ Build: http://travis-ci.org/phoet/asin.png
5
+
6
+
7
+ == Installation
8
+
9
+ gem install confiture
10
+
11
+ or in your Gemfile:
12
+
13
+ gem "confiture"
14
+
15
+ == Usage
16
+
17
+ Rails style initializer (config/initializers/asin.rb):
18
+
19
+ ASIN::Configuration.configure do |config|
20
+ config.secret = 'your-secret'
21
+ config.key = 'your-key'
22
+ end
23
+
24
+ YAML style configuration:
25
+
26
+ ASIN::Configuration.configure :yaml => 'config/asin.yml'
27
+
28
+ Inline style configuration:
29
+
30
+ ASIN::Configuration.configure :secret => 'your-secret', :key => 'your-key'
31
+ # or
32
+ client.configure :secret => 'your-secret', :key => 'your-key'
33
+
34
+ Have a look at ASIN::Configuration class for all the details.
35
+
36
+ ===API Changes
37
+
38
+ With the latest version of the Product Advertising API you need to include your associate_tag[https://affiliate-program.amazon.com/gp/advertising/api/detail/api-changes.html].
39
+
40
+ ASIN::Configuration.configure do |config|
41
+ config.secret = 'your-secret'
42
+ config.key = 'your-key'
43
+ config.associate_tag = 'your-tag'
44
+ end
45
+
46
+ == License
47
+
48
+ "THE BEER-WARE LICENSE" (Revision 42):
49
+ ps@nofail.de[mailto:ps@nofail.de] wrote this file. As long as you retain this notice you
50
+ can do whatever you want with this stuff. If we meet some day, and you think
51
+ this stuff is worth it, you can buy me a beer in return Peter Schröder
data/confiture.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "confiture/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "confiture"
7
+ s.version = Confiture::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Peter Schröder']
10
+ s.email = ['phoetmail@googlemail.com']
11
+ s.homepage = 'http://github.com/phoet/confiture'
12
+ s.summary = s.description = 'Confiture helps with configuring your gem.'
13
+
14
+ s.rubyforge_project = "confiture"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency('rake', '~> 0.9.2.2')
22
+ s.add_development_dependency('rspec', '~> 2.7.0')
23
+ end
data/lib/confiture.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Confiture
2
+ require 'confiture/version'
3
+ require 'confiture/configuration'
4
+ end
@@ -0,0 +1,89 @@
1
+ require "yaml"
2
+ require 'logger'
3
+
4
+ module Confiture
5
+ class Configuration
6
+ class << self
7
+
8
+ attr_accessor :secret, :key
9
+
10
+ # Rails initializer configuration.
11
+ #
12
+ # Expects at least +secret+ and +key+ for the API call:
13
+ #
14
+ # ASIN::Configuration.configure do |config|
15
+ # config.secret = 'your-secret'
16
+ # config.key = 'your-key'
17
+ # end
18
+ #
19
+ # With the latest version of the Product Advertising API you need to include your associate_tag[https://affiliate-program.amazon.com/gp/advertising/api/detail/api-changes.html].
20
+ #
21
+ # You may pass options as a hash as well:
22
+ #
23
+ # ASIN::Configuration.configure :secret => 'your-secret', :key => 'your-key'
24
+ #
25
+ # Or configure everything using YAML:
26
+ #
27
+ # ASIN::Configuration.configure :yaml => 'config/asin.yml'
28
+ #
29
+ # ASIN::Configuration.configure :yaml => 'config/asin.yml' do |config, yml|
30
+ # config.key = yml[Rails.env]['aws_access_key']
31
+ # end
32
+ #
33
+ # ==== Options:
34
+ #
35
+ # [secret] the API secret key (required)
36
+ # [key] the API access key (required)
37
+ # [associate_tag] your Amazon associate tag. Default is blank (required in latest API version)
38
+ # [host] the host, which defaults to 'webservices.amazon.com'
39
+ # [logger] a different logger than logging to STDERR (nil for no logging)
40
+ # [version] a custom version of the API calls. Default is 2010-11-01
41
+ # [item_type] a different class for SimpleItem, use :mash / :rash for Hashie::Mash / Hashie::Rash or :raw for a plain hash
42
+ # [cart_type] a different class for SimpleCart, use :mash / :rash for Hashie::Mash / Hashie::Rash or :raw for a plain hash
43
+ # [node_type] a different class for SimpleNode, use :mash / :rash for Hashie::Mash / Hashie::Rash or :raw for a plain hash
44
+ #
45
+ def configure(options={})
46
+ init_config
47
+ if yml_path = options[:yaml] || options[:yml]
48
+ yml = File.open(yml_path) { |file| YAML.load(file) }
49
+ if block_given?
50
+ yield self, yml
51
+ else
52
+ yml.each do |key, value|
53
+ send(:"#{key}=", value)
54
+ end
55
+ end
56
+ elsif block_given?
57
+ yield self
58
+ else
59
+ options.each do |key, value|
60
+ send(:"#{key}=", value)
61
+ end
62
+ end
63
+ self
64
+ end
65
+
66
+ # Resets configuration to defaults
67
+ #
68
+ def reset
69
+ init_config(true)
70
+ end
71
+
72
+ # Check if a key is set
73
+ #
74
+ def blank?(key)
75
+ val = self.send :key
76
+ val.nil? || val.empty?
77
+ end
78
+
79
+ private
80
+
81
+ def init_config(force=false)
82
+ return if @init && !force
83
+ @init = true
84
+ @secret = ''
85
+ @key = ''
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,3 @@
1
+ module Confiture
2
+ VERSION = "0.0.1"
3
+ end
data/rakefile.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ require "rspec/core/rake_task"
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = ["--color"]
8
+ t.pattern = 'spec/**/*_spec.rb'
9
+ end
10
+
11
+ task :default => :spec
data/spec/config.yml ADDED
@@ -0,0 +1,2 @@
1
+ secret: 'secret_yml'
2
+ key: 'key_yml'
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Confiture
4
+ describe Confiture do
5
+ context "configuration" do
6
+ it "should fail with wrong configuration key" do
7
+ lambda { @helper.configure :wrong => 'key' }.should raise_error(NoMethodError)
8
+ end
9
+
10
+ it "should work with a configuration block" do
11
+ conf = Confiture::Configuration.configure do |config|
12
+ config.key = 'bla'
13
+ end
14
+ conf.key.should eql('bla')
15
+ end
16
+
17
+ it "should read configuration from yml" do
18
+ config = Confiture::Configuration.configure :yaml => 'spec/config.yml'
19
+ config.secret.should eql('secret_yml')
20
+ config.key.should eql('key_yml')
21
+ end
22
+
23
+ it "should read configuration from yml with block" do
24
+ conf = Confiture::Configuration.configure :yaml => 'spec/config.yml' do |config, yml|
25
+ config.secret = nil
26
+ config.key = yml['secret']
27
+ end
28
+ conf.secret.should be_nil
29
+ conf.key.should eql('secret_yml')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
2
+
3
+ require 'rspec'
4
+ require 'confiture'
5
+ require 'pp'
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :rspec
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: confiture
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Schröder
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70363265328940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70363265328940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70363265328440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.7.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70363265328440
36
+ description: Confiture helps with configuring your gem.
37
+ email:
38
+ - phoetmail@googlemail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .document
44
+ - .gitignore
45
+ - .rvmrc
46
+ - .travis.yml
47
+ - CHANGELOG.rdoc
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - README.rdoc
51
+ - confiture.gemspec
52
+ - lib/confiture.rb
53
+ - lib/confiture/configuration.rb
54
+ - lib/confiture/version.rb
55
+ - rakefile.rb
56
+ - spec/config.yml
57
+ - spec/config_spec.rb
58
+ - spec/spec_helper.rb
59
+ homepage: http://github.com/phoet/confiture
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project: confiture
79
+ rubygems_version: 1.8.17
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Confiture helps with configuring your gem.
83
+ test_files:
84
+ - spec/config.yml
85
+ - spec/config_spec.rb
86
+ - spec/spec_helper.rb