fiona 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fiona"
8
- s.version = "0.0.12"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Remesch"]
12
- s.date = "2011-12-22"
12
+ s.date = "2012-07-16"
13
13
  s.description = "Easily store and use template data with Rails."
14
14
  s.email = "chad@remesch.com"
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "fiona.gemspec",
29
29
  "lib/fiona.rb",
30
+ "lib/fiona/setting_template.rb",
31
+ "lib/fiona/settings.rb",
30
32
  "lib/generators/fiona/USAGE",
31
33
  "lib/generators/fiona/fiona_generator.rb",
32
34
  "lib/generators/fiona/templates/create_fiona_tables.rb",
@@ -34,14 +36,12 @@ Gem::Specification.new do |s|
34
36
  "lib/generators/fiona/templates/settings_template.rb",
35
37
  "lib/template.rb",
36
38
  "lib/template_attribute.rb",
37
- "spec/spec_helper.rb",
38
- "spec/template_attribute_spec.rb",
39
- "spec/template_spec.rb"
39
+ "spec/spec_helper.rb"
40
40
  ]
41
41
  s.homepage = "http://github.com/BlueFrogGaming/fiona"
42
42
  s.licenses = ["MIT"]
43
43
  s.require_paths = ["lib"]
44
- s.rubygems_version = "1.8.10"
44
+ s.rubygems_version = "1.8.24"
45
45
  s.summary = "Easily store and use template data with Rails."
46
46
 
47
47
  if s.respond_to? :specification_version then
@@ -1,3 +1,5 @@
1
1
  require 'active_record'
2
2
  require 'template'
3
3
  require 'template_attribute'
4
+ require 'fiona/setting_template'
5
+ require 'fiona/settings'
@@ -0,0 +1,6 @@
1
+ module Fiona
2
+
3
+ class SettingTemplate < Template
4
+ end
5
+
6
+ end
@@ -0,0 +1,76 @@
1
+ module Fiona
2
+
3
+ class Settings
4
+ def initialize(&block)
5
+ @state = :initializing
6
+ @defaults = {}
7
+
8
+ yield(self)
9
+
10
+ merge_settings
11
+ @state = :initialized
12
+ end
13
+
14
+ def default(key, value, scope = nil)
15
+ raise 'You must set defaults when initializing' unless @state == :initializing
16
+ raise 'You must provide a key' if key.nil?
17
+ raise 'Key must be a symbol' unless key.is_a?(Symbol)
18
+ raise 'You must provide a scope' if scope.nil? && @defaults[key]
19
+ raise 'You can not change a scope' if @defaults[key] && scope
20
+ raise 'Scope must be :public or :private' if scope && ![:public, :private].include?(scope)
21
+
22
+ setting = @defaults[key] ||= {}
23
+ setting[:value] = value
24
+ setting[:scope] = scope if scope
25
+
26
+ return true
27
+ end
28
+
29
+ def all_settings
30
+ return @merged.clone
31
+ end
32
+
33
+ def public_settings
34
+ return settings_for_scope(:public)
35
+ end
36
+
37
+ def private_settings
38
+ return settings_for_scope(:private)
39
+ end
40
+
41
+ def settings_for_scope(scope)
42
+ return @merged.select { |k, v| v[:scope] == scope }
43
+ end
44
+
45
+ def reload
46
+ return merge_settings
47
+ end
48
+
49
+ def method_missing(m, *args, &block)
50
+ m = m.to_sym
51
+
52
+ if @merged.include?(m)
53
+ return @merged[m][:value]
54
+ else
55
+ raise 'Unknown key'
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def merge_settings
62
+ @merged = {}
63
+
64
+ @defaults.each do |k, v|
65
+ @merged[k] = { :value => v[:value], :scope => v[:scope] }
66
+
67
+ if (template = Fiona::SettingTemplate.find_by_key("setting_#{k}"))
68
+ @merged[k][:value] = template.value
69
+ end
70
+ end
71
+
72
+ return all_settings
73
+ end
74
+ end
75
+
76
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-22 00:00:00.000000000Z
12
+ date: 2012-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70315366117360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70315366117360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70315366116780 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.3.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70315366116780
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: bundler
38
- requirement: &70315366116160 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 1.0.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70315366116160
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: jeweler
49
- requirement: &70315366115540 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.6.4
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70315366115540
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.4
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rcov
60
- requirement: &70315366114960 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70315366114960
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rdoc
71
- requirement: &70315366114360 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70315366114360
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  description: Easily store and use template data with Rails.
81
111
  email: chad@remesch.com
82
112
  executables: []
@@ -95,6 +125,8 @@ files:
95
125
  - VERSION
96
126
  - fiona.gemspec
97
127
  - lib/fiona.rb
128
+ - lib/fiona/setting_template.rb
129
+ - lib/fiona/settings.rb
98
130
  - lib/generators/fiona/USAGE
99
131
  - lib/generators/fiona/fiona_generator.rb
100
132
  - lib/generators/fiona/templates/create_fiona_tables.rb
@@ -103,8 +135,6 @@ files:
103
135
  - lib/template.rb
104
136
  - lib/template_attribute.rb
105
137
  - spec/spec_helper.rb
106
- - spec/template_attribute_spec.rb
107
- - spec/template_spec.rb
108
138
  homepage: http://github.com/BlueFrogGaming/fiona
109
139
  licenses:
110
140
  - MIT
@@ -120,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
150
  version: '0'
121
151
  segments:
122
152
  - 0
123
- hash: 2201384770205444259
153
+ hash: -2362756093259839702
124
154
  required_rubygems_version: !ruby/object:Gem::Requirement
125
155
  none: false
126
156
  requirements:
@@ -129,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
159
  version: '0'
130
160
  requirements: []
131
161
  rubyforge_project:
132
- rubygems_version: 1.8.10
162
+ rubygems_version: 1.8.24
133
163
  signing_key:
134
164
  specification_version: 3
135
165
  summary: Easily store and use template data with Rails.
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "TemplateAttributeSpec" do
4
- end
@@ -1,13 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "TemplateSpec" do
4
- context 'serialization' do
5
- it 'should encode' do
6
- Template.serialize_attribute({'foo' => 555}).should == "{\"json\":{\"foo\":555}}"
7
- end
8
-
9
- it 'should decode' do
10
- result = Template.deserialize_attribute("{\"json\":{\"foo\":555}}")
11
- end
12
- end
13
- end