static_content 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkdn +20 -0
- data/Rakefile +4 -2
- data/app/models/content.rb +2 -1
- data/lib/generators/static_content/install/install_generator.rb +19 -0
- data/lib/static_content/version.rb +1 -1
- metadata +5 -4
data/README.mkdn
CHANGED
@@ -1,6 +1,26 @@
|
|
1
|
+
### work in progress.
|
2
|
+
|
1
3
|
#What is static_content?
|
2
4
|
static_content provides an easy way of defining static content in your application.
|
3
5
|
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'static_content'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install static_content
|
19
|
+
|
20
|
+
After install the gem, you just need run the install generator:
|
21
|
+
|
22
|
+
$ rails g static_content:install
|
23
|
+
|
4
24
|
#Usage
|
5
25
|
|
6
26
|
In your view, just add:
|
data/Rakefile
CHANGED
@@ -11,6 +11,8 @@ rescue LoadError
|
|
11
11
|
require 'rake/rdoctask'
|
12
12
|
RDoc::Task = Rake::RDocTask
|
13
13
|
end
|
14
|
+
require 'rake/testtask'
|
15
|
+
require 'rspec/core/rake_task'
|
14
16
|
|
15
17
|
RDoc::Task.new(:rdoc) do |rdoc|
|
16
18
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -20,8 +22,8 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
RSpec::Core::RakeTask.new
|
26
|
+
task :default => [:spec]
|
25
27
|
|
26
28
|
Bundler::GemHelper.install_tasks
|
27
29
|
|
data/app/models/content.rb
CHANGED
@@ -12,7 +12,8 @@ class Content < ActiveRecord::Base
|
|
12
12
|
raise NoDefaultContentError if options[:default].nil?
|
13
13
|
find_or_initialize_by_slug(slug).tap do |content|
|
14
14
|
if content.new_record?
|
15
|
-
content.
|
15
|
+
content.name = slug
|
16
|
+
content.text = options[:default]
|
16
17
|
content.save
|
17
18
|
end
|
18
19
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StaticContent
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_migrations
|
6
|
+
run 'bundle exec rake railties:install:migrations FROM=static_content'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run_migrations
|
10
|
+
res = ask 'Would you like to run the migrations now? [Y/n]'
|
11
|
+
if res == '' || res.downcase == 'y'
|
12
|
+
run 'bundle exec rake db:migrate'
|
13
|
+
else
|
14
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-08-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/static_content/version.rb
|
125
125
|
- lib/static_content/engine.rb
|
126
126
|
- lib/static_content.rb
|
127
|
+
- lib/generators/static_content/install/install_generator.rb
|
127
128
|
- lib/tasks/static_content_tasks.rake
|
128
129
|
- MIT-LICENSE
|
129
130
|
- Rakefile
|
@@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
segments:
|
144
145
|
- 0
|
145
|
-
hash: -
|
146
|
+
hash: -3656575204034588283
|
146
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
148
|
none: false
|
148
149
|
requirements:
|
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
152
|
version: '0'
|
152
153
|
segments:
|
153
154
|
- 0
|
154
|
-
hash: -
|
155
|
+
hash: -3656575204034588283
|
155
156
|
requirements: []
|
156
157
|
rubyforge_project:
|
157
158
|
rubygems_version: 1.8.24
|