unfickle 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ group :test do
4
+ gem 'rspec', '2.6.0'
5
+ gem 'ruby-debug19', require: 'ruby-debug'
6
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-tar-minitar (0.5.2)
5
+ columnize (0.3.3)
6
+ diff-lcs (1.1.2)
7
+ linecache19 (0.5.12)
8
+ ruby_core_source (>= 0.1.4)
9
+ rspec (2.6.0)
10
+ rspec-core (~> 2.6.0)
11
+ rspec-expectations (~> 2.6.0)
12
+ rspec-mocks (~> 2.6.0)
13
+ rspec-core (2.6.4)
14
+ rspec-expectations (2.6.0)
15
+ diff-lcs (~> 1.1.2)
16
+ rspec-mocks (2.6.0)
17
+ ruby-debug-base19 (0.11.25)
18
+ columnize (>= 0.3.1)
19
+ linecache19 (>= 0.5.11)
20
+ ruby_core_source (>= 0.1.4)
21
+ ruby-debug19 (0.11.6)
22
+ columnize (>= 0.3.1)
23
+ linecache19 (>= 0.5.11)
24
+ ruby-debug-base19 (>= 0.11.19)
25
+ ruby_core_source (0.1.5)
26
+ archive-tar-minitar (>= 0.5.2)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ rspec (= 2.6.0)
33
+ ruby-debug19
data/README ADDED
@@ -0,0 +1,10 @@
1
+ This allows for better constant management. Use it like so:
2
+ class MyClass
3
+ include Unfickle
4
+
5
+ self.add_item(:SOMECONST, 1)
6
+ end
7
+
8
+ You can then reference it directly like so:
9
+
10
+ MyClass::SOMECONST
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'unfickle/unfickle'
@@ -0,0 +1,30 @@
1
+ module Unfickle
2
+ def add_item(key,value)
3
+ @hash ||= {}
4
+ @hash[key]=value
5
+ end
6
+
7
+ def const_missing(key)
8
+ @hash[key]
9
+ end
10
+
11
+ def each
12
+ @hash.each {|key,value| yield(key,value)}
13
+ end
14
+
15
+ def values
16
+ @hash.values || []
17
+ end
18
+
19
+ def keys
20
+ @hash.keys || []
21
+ end
22
+
23
+ def [](key)
24
+ @hash[key]
25
+ end
26
+
27
+ def clear
28
+ @hash = {}
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Unfickle
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Unfickle do
4
+ subject do
5
+ class TestClass
6
+ include Unfickle
7
+ extend Unfickle
8
+ end
9
+ TestClass
10
+ end
11
+
12
+ before(:each) do
13
+ subject.clear
14
+ subject.add_item(:BLAH, 'value')
15
+ end
16
+
17
+
18
+ describe '.add_item' do
19
+ it "has a blah 'constant'" do
20
+ subject.add_item(:YAHOO, 'sucks')
21
+ subject::YAHOO.should == 'sucks'
22
+ end
23
+ end
24
+
25
+ describe '.const_missing' do
26
+ it 'just returns nil' do
27
+ subject.const_missing(:YEEHAH).should == nil
28
+ end
29
+ end
30
+
31
+ describe '.each' do
32
+ it 'iterates over all the keys' do
33
+ subject.each do |key, value|
34
+ key.should == :BLAH
35
+ value.should == 'value'
36
+ end
37
+ end
38
+ end
39
+
40
+ describe 'values' do
41
+ context 'with values' do
42
+ its(:values) { should == ['value'] }
43
+ end
44
+
45
+ context 'without values' do
46
+ before(:each) { subject.clear }
47
+ its(:values) { should == [] }
48
+ end
49
+ end
50
+
51
+ describe 'keys' do
52
+ context 'with keys' do
53
+ its(:keys) { should == [:BLAH] }
54
+ end
55
+
56
+ context 'without keys' do
57
+ before(:each) { subject.clear }
58
+ its(:keys) { should == [] }
59
+ end
60
+ end
61
+
62
+ describe '[]' do
63
+ it 'response like an array' do
64
+ subject[:BLAH].should == 'value'
65
+ end
66
+ end
67
+
68
+ describe 'clear' do
69
+ it 'clears the constants' do
70
+ subject.clear
71
+ subject.keys.should == []
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :test
4
+
5
+ RSpec.configure do |c|
6
+ c.mock_with :rspec
7
+ end
8
+
9
+ require 'fileutils'
10
+
11
+ # Fix the loadpath for specs
12
+ $:.push File.expand_path('../lib', File.dirname(__FILE__))
13
+ $:.push File.expand_path('../spec', File.dirname(__FILE__))
14
+
15
+ require 'unfickle'
16
+
17
+
18
+ Dir[File.expand_path("spec/support/**/*.rb")].each {|f| require f}
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
+ require 'unfickle/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'unfickle'
7
+ s.version = Unfickle::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Tracey Eubanks']
10
+ s.email = ['tracey.eubanks@moneydesktop.com', 'traceyeubanks@yahoo.com']
11
+ s.summary = 'Help clean up code by using unfickle for constant declaration'
12
+ s.description = 'Help clean up code by using unfickle for constant declaration'
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+
16
+ s.add_development_dependency 'bundler', '~> 1.0.0'
17
+ s.add_development_dependency 'rspec', '~> 2.0.0'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.require_path = 'lib'
21
+ end
22
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unfickle
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Tracey Eubanks
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-16 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.0
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 2.0.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ description: Help clean up code by using unfickle for constant declaration
39
+ email:
40
+ - tracey.eubanks@moneydesktop.com
41
+ - traceyeubanks@yahoo.com
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ extra_rdoc_files: []
47
+
48
+ files:
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README
52
+ - lib/unfickle.rb
53
+ - lib/unfickle/unfickle.rb
54
+ - lib/unfickle/version.rb
55
+ - spec/lib/unfickle/unfickle_spec.rb
56
+ - spec/spec_helper.rb
57
+ - unfickle.gemspec
58
+ has_rdoc: true
59
+ homepage:
60
+ licenses: []
61
+
62
+ post_install_message:
63
+ rdoc_options: []
64
+
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.6
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.6.1
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Help clean up code by using unfickle for constant declaration
86
+ test_files: []
87
+