whitelabel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in whitelabel.gemspec
4
+ gemspec
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ whitelabel (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.0.6)
10
+ diff-lcs (1.1.3)
11
+ method_source (0.7.1)
12
+ pry (0.9.8.4)
13
+ coderay (~> 1.0.5)
14
+ method_source (~> 0.7.1)
15
+ slop (>= 2.4.4, < 3)
16
+ rspec (2.9.0)
17
+ rspec-core (~> 2.9.0)
18
+ rspec-expectations (~> 2.9.0)
19
+ rspec-mocks (~> 2.9.0)
20
+ rspec-core (2.9.0)
21
+ rspec-expectations (2.9.1)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.9.0)
24
+ slop (2.4.4)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ pry (~> 0.9)
31
+ rspec (~> 2.9)
32
+ whitelabel!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Peter Schröder
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.
@@ -0,0 +1,29 @@
1
+ # Whitelabel
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'whitelabel'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install whitelabel
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ require "whitelabel/version"
2
+
3
+ require "yaml"
4
+
5
+ module Whitelabel
6
+ class << self
7
+ attr_accessor :labels
8
+
9
+ def from_file(path)
10
+ @labels = File.open(path) { |file| YAML.load(file) }
11
+ end
12
+
13
+ def label
14
+ Thread.current[:whitelabel]
15
+ end
16
+
17
+ def label=(label)
18
+ Thread.current[:whitelabel] = label
19
+ end
20
+
21
+ def label_for(pattern, identifier=:label_id)
22
+ self.label = @labels.find { |label| label.send(identifier) =~ /^#{pattern}$/ }
23
+ end
24
+
25
+ def [](accessor)
26
+ self.label.send :"#{accessor}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Whitelabel
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ ---
2
+ - &70266423416560 !ruby/struct:Dummy
3
+ label_id: test
4
+ name: bla
5
+ - *70266423416560
@@ -0,0 +1,47 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe Whitelabel do
5
+ let(:path) { fixture_path("whitelabel.yml") }
6
+
7
+ before(:each) do
8
+ Whitelabel.labels = []
9
+ end
10
+
11
+ context "initialization" do
12
+ it "should load from a file" do
13
+ expect { Whitelabel.from_file(path) }.to change { Whitelabel.labels.size }.by(2)
14
+ end
15
+ end
16
+
17
+ context "label" do
18
+ before(:each) do
19
+ Whitelabel.from_file(path)
20
+ end
21
+
22
+ it "should work thread safe" do
23
+ Whitelabel.label = :bla
24
+ Thread.new { Whitelabel.label = nil }
25
+ Whitelabel.label.should_not be_nil
26
+ end
27
+
28
+ it "should find a label for a pattern" do
29
+ Whitelabel.label_for('uschi').should_not be_nil
30
+ Whitelabel.label.name.should eql('Uschi Müller')
31
+ end
32
+
33
+ it "should not find a label for a missing pattern" do
34
+ Whitelabel.label_for('').should be_nil
35
+ end
36
+
37
+ context "with current label" do
38
+ before(:each) do
39
+ Whitelabel.label = Dummy.new('some_id', 'some_name')
40
+ end
41
+
42
+ it "should access a label property via []" do
43
+ Whitelabel[:name].should eql('some_name')
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ require "whitelabel"
2
+
3
+ require "pry"
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ end
10
+
11
+ def fixture_path(name)
12
+ File.expand_path "fixtures/#{name}", File.dirname(__FILE__)
13
+ end
14
+
15
+ Dummy = Struct.new(:label_id, :name)
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/whitelabel/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Peter Schröder"]
6
+ gem.email = ["phoetmail@googlemail.com"]
7
+ gem.description = %q{whitelabel your application}
8
+ gem.summary = %q{use this gem if you want to provide whitelabel functionality for your app}
9
+ gem.homepage = "https://github.com/phoet/whitelabel"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "whitelabel"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Whitelabel::VERSION
17
+
18
+ gem.add_development_dependency('rspec', '~> 2.9')
19
+ gem.add_development_dependency('pry', '~> 0.9')
20
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whitelabel
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-05-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70306368111360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.9'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70306368111360
25
+ - !ruby/object:Gem::Dependency
26
+ name: pry
27
+ requirement: &70306368110860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70306368110860
36
+ description: whitelabel your application
37
+ email:
38
+ - phoetmail@googlemail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .rspec
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - lib/whitelabel.rb
50
+ - lib/whitelabel/version.rb
51
+ - spec/fixtures/whitelabel.yml
52
+ - spec/lib/whitelabel_spec.rb
53
+ - spec/spec_helper.rb
54
+ - whitelabel.gemspec
55
+ homepage: https://github.com/phoet/whitelabel
56
+ licenses: []
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.17
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: use this gem if you want to provide whitelabel functionality for your app
79
+ test_files:
80
+ - spec/fixtures/whitelabel.yml
81
+ - spec/lib/whitelabel_spec.rb
82
+ - spec/spec_helper.rb