static_content 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b96b29f32e5ec682af8ef897b4946e0e45672d4
4
+ data.tar.gz: da75498713b5be45fe10a6edd40e1890916adf88
5
+ SHA512:
6
+ metadata.gz: aa11dbfffa985a41e41471588c52165d985ae6501df659e19aa57b037c99773d53f9aeadce1402d11ded41028e6cfa83e4150e3b9387dc96b6c20b02e3a62ee3
7
+ data.tar.gz: 29824092fca7e251b4c11a57002ebb108dd46c00c588b37d8083b4abd0b0d73057741c8d8b8d9b5942e10c8c9307c8c03acfd9f1950ed8119a126040961bf81c
data/README.md CHANGED
@@ -31,21 +31,9 @@ After install the gem, you just need run the install generator:
31
31
 
32
32
  The content we create can be normal text or a markdown. Let`s see the way we can create a content.
33
33
 
34
- #### Standard Way
34
+ Use the `StaticContent::Content.from_slug` like:
35
35
 
36
- You can create as a normal model with:
37
-
38
- Content.create({slug: :about_title, text: "My awesome about page"}, as: :admin)
39
-
40
- special attention to the `as: :admin`, the fields is only acessible to `admin`.
41
-
42
- This is intended to be used with admin panels such as Typus or ActiveAdmin.
43
-
44
- #### The better way
45
-
46
- The better way is to use the `Content.from_slug` like:
47
-
48
- Content.from_slug(:about_title, default: "My awesome about page")
36
+ StaticContent::Content.from_slug(:about_title, default: "My awesome about page")
49
37
 
50
38
  as this uses `find_or_initialize`, if is a new `slug` its create, if a old one its only return the value not raising a error.
51
39
 
@@ -85,10 +73,6 @@ no change the value as
85
73
 
86
74
  Please note that a `default` option is required. If it hasn't been created, it will be created upon the first request.
87
75
 
88
- ## Warning
89
-
90
- Static Content generates a model [`Content`](https://github.com/Helabs/static_content/blob/master/app/models/content.rb) and a table [`contents`](https://github.com/Helabs/static_content/blob/master/db/migrate/20120705141451_create_contents.rb), so your app should not contain this model and table.
91
-
92
76
  ## Versioning
93
77
 
94
78
  Static Content follow the [Semantic Versioning](http://semver.org/).
@@ -101,6 +85,17 @@ If you have problems, please create a [Github Issue](https://github.com/Helabs/s
101
85
 
102
86
  Please see [CONTRIBUTING.md](https://github.com/Helabs/static_content/blob/master/CONTRIBUTING.md) for details.
103
87
 
88
+ ## Release
89
+
90
+ Follow this steps to release a new version of the gem.
91
+
92
+ 1. Test if everything is running ok;
93
+ 1. Change version of the gem on `VERSION` constant;
94
+ 1. Add the release date on the `CHANGELOG`;
95
+ 1. Do a commit "Bump version x.x.x", follow the semantic version;
96
+ 1. Run `$ rake release`, this will send the gem to the rubygems;
97
+ 1. Check if the gem is on the rubygems and the tags are correct on the github;
98
+
104
99
  ## Credits
105
100
 
106
101
  Static Content is maintained and funded by [HE:labs](http://helabs.com.br/opensource/).
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  begin
3
3
  require 'bundler/setup'
4
+ require 'appraisal'
4
5
  rescue LoadError
5
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
7
  end
@@ -0,0 +1,14 @@
1
+ module StaticContent
2
+ module ContentHelper
3
+
4
+ def content(*args)
5
+ StaticContent::Content.from_slug(*args).parsed_text
6
+ end
7
+ alias :c :content
8
+
9
+ def raw_content(*args)
10
+ StaticContent::Content.from_slug(*args).raw_text
11
+ end
12
+ alias :rc :raw_content
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ require 'rdiscount' #TODO: Fix this stupid require statement.
2
+ module StaticContent
3
+ class Content < ActiveRecord::Base
4
+
5
+ validates :slug, :text, presence: true
6
+ validates :slug, uniqueness: true
7
+
8
+ def self.from_slug(slug, options={})
9
+ raise ArgumentError.new("You must provide a default text for a content.") if options[:default].nil?
10
+ where(slug: slug).first_or_initialize.tap do |content|
11
+ if content.new_record?
12
+ content.text = options[:default]
13
+ content.save
14
+ end
15
+ end
16
+ end
17
+
18
+ def parsed_text
19
+ markdown.to_html.html_safe
20
+ end
21
+
22
+ def raw_text
23
+ text.html_safe
24
+ end
25
+
26
+ private
27
+
28
+ def markdown
29
+ @content ||= RDiscount.new(text)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,10 @@
1
+ class CreateStaticContentContents < ActiveRecord::Migration
2
+ def change
3
+ create_table :static_content_contents do |t|
4
+ t.string :slug
5
+ t.text :text
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,14 @@
1
1
  module StaticContent
2
2
  class Engine < ::Rails::Engine
3
+ isolate_namespace StaticContent
3
4
  engine_name "static_content"
5
+
6
+ initializer 'static_content.action_controller' do |app|
7
+ ActiveSupport.on_load :action_controller do
8
+ ActionView::Base.send :include, StaticContent::ContentHelper
9
+ end
10
+ end
11
+
12
+
4
13
  end
5
14
  end
@@ -1,3 +1,3 @@
1
1
  module StaticContent
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
5
- prerelease:
4
+ version: 2.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pedro Nascimento
@@ -12,28 +11,31 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-06-28 00:00:00.000000000 Z
14
+ date: 2014-01-31 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: rails
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ~>
20
+ - - '>='
23
21
  - !ruby/object:Gem::Version
24
22
  version: 3.2.6
23
+ - - <
24
+ - !ruby/object:Gem::Version
25
+ version: '5'
25
26
  type: :runtime
26
27
  prerelease: false
27
28
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
29
  requirements:
30
- - - ~>
30
+ - - '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.2.6
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '5'
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: rdiscount
35
38
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
39
  requirements:
38
40
  - - ~>
39
41
  - !ruby/object:Gem::Version
@@ -41,7 +43,6 @@ dependencies:
41
43
  type: :runtime
42
44
  prerelease: false
43
45
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
46
  requirements:
46
47
  - - ~>
47
48
  - !ruby/object:Gem::Version
@@ -49,81 +50,85 @@ dependencies:
49
50
  - !ruby/object:Gem::Dependency
50
51
  name: sqlite3
51
52
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
53
  requirements:
54
- - - ! '>='
54
+ - - '>='
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
60
  requirements:
62
- - - ! '>='
61
+ - - '>='
63
62
  - !ruby/object:Gem::Version
64
63
  version: '0'
65
64
  - !ruby/object:Gem::Dependency
66
65
  name: coveralls
67
66
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
67
  requirements:
70
- - - ! '>='
68
+ - - '>='
71
69
  - !ruby/object:Gem::Version
72
70
  version: '0'
73
71
  type: :development
74
72
  prerelease: false
75
73
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
74
  requirements:
78
- - - ! '>='
75
+ - - '>='
79
76
  - !ruby/object:Gem::Version
80
77
  version: '0'
81
78
  - !ruby/object:Gem::Dependency
82
79
  name: rspec-rails
83
80
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
81
  requirements:
86
- - - ! '>='
82
+ - - '>='
87
83
  - !ruby/object:Gem::Version
88
84
  version: '0'
89
85
  type: :development
90
86
  prerelease: false
91
87
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
88
  requirements:
94
- - - ! '>='
89
+ - - '>='
95
90
  - !ruby/object:Gem::Version
96
91
  version: '0'
97
92
  - !ruby/object:Gem::Dependency
98
93
  name: factory_girl_rails
99
94
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
95
  requirements:
102
- - - ! '>='
96
+ - - '>='
103
97
  - !ruby/object:Gem::Version
104
98
  version: '0'
105
99
  type: :development
106
100
  prerelease: false
107
101
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
102
  requirements:
110
- - - ! '>='
103
+ - - '>='
111
104
  - !ruby/object:Gem::Version
112
105
  version: '0'
113
106
  - !ruby/object:Gem::Dependency
114
107
  name: shoulda-matchers
115
108
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
109
  requirements:
118
- - - ! '>='
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ - !ruby/object:Gem::Dependency
121
+ name: appraisal
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
119
125
  - !ruby/object:Gem::Version
120
126
  version: '0'
121
127
  type: :development
122
128
  prerelease: false
123
129
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
130
  requirements:
126
- - - ! '>='
131
+ - - '>='
127
132
  - !ruby/object:Gem::Version
128
133
  version: '0'
129
134
  description: static_content provides a simple way of outputting static content in
@@ -134,10 +139,10 @@ executables: []
134
139
  extensions: []
135
140
  extra_rdoc_files: []
136
141
  files:
137
- - app/helpers/content_helper.rb
138
- - app/models/content.rb
142
+ - app/helpers/static_content/content_helper.rb
143
+ - app/models/static_content/content.rb
139
144
  - config/routes.rb
140
- - db/migrate/20120705141451_create_contents.rb
145
+ - db/migrate/20130927193859_create_static_content_contents.rb
141
146
  - lib/generators/static_content/install/install_generator.rb
142
147
  - lib/static_content/engine.rb
143
148
  - lib/static_content/version.rb
@@ -148,33 +153,26 @@ files:
148
153
  - README.md
149
154
  homepage: https://github.com/Helabs/static_content
150
155
  licenses: []
156
+ metadata: {}
151
157
  post_install_message:
152
158
  rdoc_options: []
153
159
  require_paths:
154
160
  - lib
155
161
  required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
162
  requirements:
158
- - - ! '>='
163
+ - - '>='
159
164
  - !ruby/object:Gem::Version
160
165
  version: '0'
161
- segments:
162
- - 0
163
- hash: -4120352764059079523
164
166
  required_rubygems_version: !ruby/object:Gem::Requirement
165
- none: false
166
167
  requirements:
167
- - - ! '>='
168
+ - - '>='
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
- segments:
171
- - 0
172
- hash: -4120352764059079523
173
171
  requirements: []
174
172
  rubyforge_project:
175
- rubygems_version: 1.8.25
173
+ rubygems_version: 2.0.3
176
174
  signing_key:
177
- specification_version: 3
175
+ specification_version: 4
178
176
  summary: static_content provides a simple way of outputting static content in your
179
177
  app.
180
178
  test_files: []
@@ -1,12 +0,0 @@
1
- module ContentHelper
2
-
3
- def content(*args)
4
- Content.from_slug(*args).parsed_text
5
- end
6
- alias :c :content
7
-
8
- def raw_content(*args)
9
- Content.from_slug(*args).raw_text
10
- end
11
- alias :rc :raw_content
12
- end
@@ -1,33 +0,0 @@
1
- require 'rdiscount' #TODO: Fix this stupid require statement.
2
- class Content < ActiveRecord::Base
3
-
4
- attr_accessible :slug, :text, as: :admin
5
-
6
- validates :slug, :text, presence: true
7
- validates :slug, uniqueness: true
8
-
9
- def self.from_slug(slug, options={})
10
- raise ArgumentError.new("You must provide a default text for a content.") if options[:default].nil?
11
- find_or_initialize_by_slug(slug).tap do |content|
12
- if content.new_record?
13
- content.text = options[:default]
14
- content.save
15
- end
16
- end
17
- end
18
-
19
- def parsed_text
20
- markdown.to_html.html_safe
21
- end
22
-
23
- def raw_text
24
- text.html_safe
25
- end
26
-
27
- private
28
-
29
- def markdown
30
- @content ||= RDiscount.new(text)
31
- end
32
- end
33
-
@@ -1,10 +0,0 @@
1
- class CreateContents < ActiveRecord::Migration
2
- def change
3
- create_table :contents do |t|
4
- t.string :slug
5
- t.text :text
6
-
7
- t.timestamps
8
- end
9
- end
10
- end