static_model 0.3.2 → 1.0.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.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.0 2011-08-20
2
+
3
+ * Remove ActiveSupport as a dependency (StaticModel has no direct dependencies now)
4
+ * Fix Rails 3 compatability, you might need to explicitly set your load path
5
+ with StaticModel::Base.load_path=
6
+
1
7
  == 0.3.1 2010-10-22
2
8
 
3
9
  * Ruby 1.9.2 Compatibility fixes
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
1
+ %w[rubygems rake psych rake/clean rake/testtask fileutils].each { |f| require f }
2
2
  require File.dirname(__FILE__) + '/lib/static_model'
3
3
 
4
4
  begin
@@ -6,15 +6,13 @@ begin
6
6
  Jeweler::Tasks.new do |s|
7
7
  s.name = %q{static_model}
8
8
  s.version = StaticModel::VERSION
9
- s.email = %{aaron at quirkey dot com}
9
+ s.email = %{aaron@quirkey.com}
10
10
  s.homepage = "http://github.com/quirkey/static_model"
11
11
  s.authors = ["Aaron Quint"]
12
12
  s.date = %q{2009-12-03}
13
13
  s.summary = 'ActiveRecord like functionalities for reading from YAML with a simple class implementation'
14
14
  s.description = %q{StaticModel provides a Base class much like ActiveRecord which supports reading from a YAML file and basic associations to ActiveRecord}
15
15
  s.rubyforge_project = %q{quirkey}
16
- s.add_runtime_dependency(%q<activesupport>, ["~>2.3.8"])
17
- # s.add_runtime_dependency(%q<rubigen>, [">= 1.5.1"])
18
16
  s.add_development_dependency(%q<Shoulda>, [">= 1.2.0"])
19
17
  end
20
18
  Jeweler::GemcutterTasks.new
data/lib/static_model.rb CHANGED
@@ -4,16 +4,13 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'yaml' unless defined?(YAML)
5
5
  require 'erb' unless defined?(ERB)
6
6
 
7
- gem 'activesupport', '~>2.3.8'
8
- require 'active_support'
9
-
10
7
  module StaticModel
11
- VERSION = '0.3.2'
8
+ VERSION = '1.0.0'
12
9
  end
13
10
 
11
+ require 'static_model/active_support'
14
12
  require 'static_model/errors'
15
13
  require 'static_model/associations'
16
14
  require 'static_model/active_record'
17
15
  require 'static_model/comparable'
18
16
  require 'static_model/base'
19
- require 'static_model/rails'
@@ -0,0 +1,40 @@
1
+ # Naive fallbacks for ActiveSupport String extensions. Uses ActiveSupport if its
2
+ # available, otherwise, use these so at least it doesnt require AS and its a
3
+ # little faster for the common case
4
+ class String
5
+
6
+ unless method_defined?(:foreign_key)
7
+ def foreign_key
8
+ self.gsub(/^.*::/, '').underscore + "_id"
9
+ end
10
+
11
+ def classify
12
+ self.gsub(/.*\./, '').singularize.camelize
13
+ end
14
+
15
+ def camelize
16
+ self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
17
+ end
18
+
19
+ def singularize
20
+ self.gsub(/s$/, '')
21
+ end
22
+
23
+ def tableize
24
+ self.underscore.pluralize
25
+ end
26
+
27
+ def pluralize
28
+ self + "s"
29
+ end
30
+
31
+ def underscore
32
+ self.gsub(/::/, '/').
33
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
34
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
35
+ tr("-", "_").
36
+ downcase
37
+ end
38
+ end
39
+
40
+ end
@@ -4,7 +4,13 @@ module StaticModel
4
4
  include StaticModel::ActiveRecord
5
5
  include StaticModel::Comparable
6
6
 
7
- @@load_path = File.join('config', 'data')
7
+ def self.load_path
8
+ @@load_path ||= File.join('config', 'data')
9
+ end
10
+
11
+ def self.load_path=(path)
12
+ @@load_path = path
13
+ end
8
14
 
9
15
  attr_reader :id
10
16
 
@@ -187,7 +193,7 @@ module StaticModel
187
193
 
188
194
  protected
189
195
  def default_data_file_path
190
- File.join(@@load_path, "#{self.to_s.tableize}.yml")
196
+ File.join(self.class.load_path, "#{self.to_s.tableize}.yml")
191
197
  end
192
198
 
193
199
  private
@@ -1,7 +1,3 @@
1
- if defined?(Rails)
2
- module StaticModel
3
- class Base
4
- @@load_path = File.join(Rails.root,'config', 'data')
5
- end
6
- end
7
- end
1
+ if defined?(Rails) && Rails.root
2
+ StaticModel::Base.load_path = File.join(Rails.root,'config', 'data')
3
+ end
data/static_model.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{static_model}
8
- s.version = "0.3.2"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
12
  s.date = %q{2009-12-03}
13
13
  s.description = %q{StaticModel provides a Base class much like ActiveRecord which supports reading from a YAML file and basic associations to ActiveRecord}
14
- s.email = %q{aaron at quirkey dot com}
14
+ s.email = %q{aaron@quirkey.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "index.html",
28
28
  "lib/static_model.rb",
29
29
  "lib/static_model/active_record.rb",
30
+ "lib/static_model/active_support.rb",
30
31
  "lib/static_model/associations.rb",
31
32
  "lib/static_model/base.rb",
32
33
  "lib/static_model/comparable.rb",
@@ -52,30 +53,18 @@ Gem::Specification.new do |s|
52
53
  s.homepage = %q{http://github.com/quirkey/static_model}
53
54
  s.require_paths = ["lib"]
54
55
  s.rubyforge_project = %q{quirkey}
55
- s.rubygems_version = %q{1.3.7}
56
+ s.rubygems_version = %q{1.6.2}
56
57
  s.summary = %q{ActiveRecord like functionalities for reading from YAML with a simple class implementation}
57
- s.test_files = [
58
- "test/test_generator_helper.rb",
59
- "test/test_helper.rb",
60
- "test/test_static_model.rb",
61
- "test/test_static_model_associations.rb",
62
- "test/test_static_model_generator.rb",
63
- "test/test_static_model_scope.rb"
64
- ]
65
58
 
66
59
  if s.respond_to? :specification_version then
67
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
60
  s.specification_version = 3
69
61
 
70
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
- s.add_runtime_dependency(%q<activesupport>, ["~> 2.3.8"])
72
63
  s.add_development_dependency(%q<Shoulda>, [">= 1.2.0"])
73
64
  else
74
- s.add_dependency(%q<activesupport>, ["~> 2.3.8"])
75
65
  s.add_dependency(%q<Shoulda>, [">= 1.2.0"])
76
66
  end
77
67
  else
78
- s.add_dependency(%q<activesupport>, ["~> 2.3.8"])
79
68
  s.add_dependency(%q<Shoulda>, [">= 1.2.0"])
80
69
  end
81
70
  end
metadata CHANGED
@@ -1,61 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: static_model
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Aaron Quint
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2009-12-03 00:00:00 -05:00
12
+ date: 2009-12-03 00:00:00.000000000 -05:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: activesupport
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 3
31
- - 8
32
- version: 2.3.8
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
36
16
  name: Shoulda
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
17
+ requirement: &2152745440 !ruby/object:Gem::Requirement
39
18
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 1
45
- - 2
46
- - 0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
47
22
  version: 1.2.0
48
23
  type: :development
49
- version_requirements: *id002
50
- description: StaticModel provides a Base class much like ActiveRecord which supports reading from a YAML file and basic associations to ActiveRecord
51
- email: aaron at quirkey dot com
24
+ prerelease: false
25
+ version_requirements: *2152745440
26
+ description: StaticModel provides a Base class much like ActiveRecord which supports
27
+ reading from a YAML file and basic associations to ActiveRecord
28
+ email: aaron@quirkey.com
52
29
  executables: []
53
-
54
30
  extensions: []
55
-
56
- extra_rdoc_files:
31
+ extra_rdoc_files:
57
32
  - README.rdoc
58
- files:
33
+ files:
59
34
  - History.txt
60
35
  - License.txt
61
36
  - README.rdoc
@@ -67,6 +42,7 @@ files:
67
42
  - index.html
68
43
  - lib/static_model.rb
69
44
  - lib/static_model/active_record.rb
45
+ - lib/static_model/active_support.rb
70
46
  - lib/static_model/associations.rb
71
47
  - lib/static_model/base.rb
72
48
  - lib/static_model/comparable.rb
@@ -91,39 +67,27 @@ files:
91
67
  has_rdoc: true
92
68
  homepage: http://github.com/quirkey/static_model
93
69
  licenses: []
94
-
95
70
  post_install_message:
96
71
  rdoc_options: []
97
-
98
- require_paths:
72
+ require_paths:
99
73
  - lib
100
- required_ruby_version: !ruby/object:Gem::Requirement
74
+ required_ruby_version: !ruby/object:Gem::Requirement
101
75
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- segments:
106
- - 0
107
- version: "0"
108
- required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
81
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- segments:
114
- - 0
115
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
116
86
  requirements: []
117
-
118
87
  rubyforge_project: quirkey
119
- rubygems_version: 1.3.7
88
+ rubygems_version: 1.6.2
120
89
  signing_key:
121
90
  specification_version: 3
122
- summary: ActiveRecord like functionalities for reading from YAML with a simple class implementation
123
- test_files:
124
- - test/test_generator_helper.rb
125
- - test/test_helper.rb
126
- - test/test_static_model.rb
127
- - test/test_static_model_associations.rb
128
- - test/test_static_model_generator.rb
129
- - test/test_static_model_scope.rb
91
+ summary: ActiveRecord like functionalities for reading from YAML with a simple class
92
+ implementation
93
+ test_files: []