dummier 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +40 -11
- data/lib/dummier/app_generator.rb +1 -0
- data/lib/dummier/version.rb +1 -1
- data/test/unit/dummier_test.rb +8 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -9,7 +9,7 @@ The idea behind Dummier is that we don't check `test/dummy` into git, but rather
|
|
9
9
|
|
10
10
|
Dummier is simple; just run the binary from your gem's root directory and it will generate a stripped-down & gem-dev-ready rails app in `test/dummy`. While it's doing it's thing, Dummer triggers a few hooks along the way for easy customization.
|
11
11
|
|
12
|
-
To catch the hooks, just create appropriatly named files in `lib/dummy_hooks` inside your gem. See
|
12
|
+
To catch the hooks, just create appropriatly named files in `lib/dummy_hooks` inside your gem. See **Hooks** below for more info.
|
13
13
|
|
14
14
|
|
15
15
|
Installation
|
@@ -19,6 +19,9 @@ To install from RubyGems:
|
|
19
19
|
|
20
20
|
gem install dummier
|
21
21
|
|
22
|
+
To install with bundler:
|
23
|
+
|
24
|
+
gem 'dummier', '>= 0.1.0'
|
22
25
|
|
23
26
|
To package for development in your gemspec:
|
24
27
|
|
@@ -28,14 +31,19 @@ To package for development in your gemspec:
|
|
28
31
|
Usage
|
29
32
|
-----
|
30
33
|
|
31
|
-
After you've installed Dummier, just cd into the gem your developing and run:
|
34
|
+
After you've installed Dummier, just `cd` into the gem your developing and run the binary:
|
35
|
+
|
36
|
+
dummier
|
37
|
+
|
38
|
+
If you're in a gem that uses bundler, you may have to run the binary with `bundle exec`:
|
32
39
|
|
33
40
|
bundle exec dummier
|
34
41
|
|
35
42
|
|
36
|
-
|
43
|
+
Hooks
|
44
|
+
-----
|
37
45
|
|
38
|
-
Dummier calls the
|
46
|
+
Dummier calls the following hooks along the way:
|
39
47
|
|
40
48
|
before_delete
|
41
49
|
before_app_generator
|
@@ -43,12 +51,13 @@ Dummier calls the follow hooks along the way:
|
|
43
51
|
before_migrate
|
44
52
|
after_migrate
|
45
53
|
|
54
|
+
|
46
55
|
Place appropriatly named files in `lib/dummy_hooks` and dummier will find and execute them automatically!
|
47
56
|
|
48
|
-
You can use [Rails::Generators::Actions](http://api.rubyonrails.org/classes/Rails/Generators/Actions.html) as well as [Thor::Actions](http://textmate.rubyforge.org/thor/Thor/Actions.html) in your hooks. Also, since hooks are just `eval`'d into the Dummer::AppGenerator, you have access to all of [those methods](http://rubydoc.info/gems/dummier/0.1.0/Dummier/AppGenerator) as well.
|
57
|
+
You can use [Rails::Generators::Actions](http://api.rubyonrails.org/classes/Rails/Generators/Actions.html) as well as [Thor::Actions](http://textmate.rubyforge.org/thor/Thor/Actions.html) in your hooks. Also, since hooks are just `eval`'d into the [Dummer::AppGenerator](http://rubydoc.info/gems/dummier/0.1.0/Dummier/AppGenerator), you have access to all of [those methods](http://rubydoc.info/gems/dummier/0.1.0/Dummier/AppGenerator) as well.
|
49
58
|
|
50
59
|
|
51
|
-
### Example
|
60
|
+
### Simple Example
|
52
61
|
|
53
62
|
Here's a `before_migrate.rb` hook that will install [Spree Commerce](https://github.com/spree/spree) by running some rake commands before migrating the `test/dummy` database.
|
54
63
|
|
@@ -57,6 +66,24 @@ Here's a `before_migrate.rb` hook that will install [Spree Commerce](https://git
|
|
57
66
|
rake "spree_core:install spree_auth:install spree_sample:install"
|
58
67
|
|
59
68
|
|
69
|
+
### More Complex Example
|
70
|
+
|
71
|
+
Here's an example taken from [has_magick_title](https://github.com/citrus/has_magick_title):
|
72
|
+
|
73
|
+
# lib/dummy_hooks/after_app_generator.rb
|
74
|
+
run "rails g scaffold post title:string"
|
75
|
+
|
76
|
+
gsub_file "app/models/post.rb", "end", %(
|
77
|
+
has_magick_title
|
78
|
+
|
79
|
+
end)
|
80
|
+
|
81
|
+
gsub_file "config/routes.rb", "resources :posts", %(
|
82
|
+
resources :posts
|
83
|
+
root :to => "posts#index")
|
84
|
+
|
85
|
+
gsub_file "app/views/posts/show.html.erb", "<%= @post.title %>", %(
|
86
|
+
<%= magick_title_for @post %>)
|
60
87
|
|
61
88
|
|
62
89
|
Testing
|
@@ -69,22 +96,24 @@ To get setup for testing, clone this repo, bundle up and run rake.
|
|
69
96
|
bundle install
|
70
97
|
rake
|
71
98
|
|
72
|
-
Enjoy!
|
73
99
|
|
100
|
+
Enjoy!
|
74
101
|
|
75
102
|
|
76
103
|
Change Log
|
77
104
|
----------
|
78
105
|
|
79
|
-
**2011/
|
106
|
+
**0.1.1 - 2011/6/1**
|
107
|
+
|
108
|
+
* added your gem's `lib/dummy_hooks/templates` folder into the generator's `source_paths`
|
109
|
+
|
110
|
+
**0.1.0 - 2011/5/20**
|
80
111
|
|
81
|
-
* released 0.1.0 to rubygems
|
82
112
|
* removed spork and wrote a basic hook test
|
83
113
|
* improved documentation
|
84
114
|
|
85
|
-
**2011/5/11**
|
115
|
+
**0.1.0.rc1 - 2011/5/11**
|
86
116
|
|
87
|
-
* released 0.1.0.rc1 to rubygems
|
88
117
|
* added spork and some tests
|
89
118
|
|
90
119
|
**2011/5/10**
|
@@ -20,6 +20,7 @@ module Dummier
|
|
20
20
|
@root_path = File.expand_path(root)
|
21
21
|
@destination_stack = []
|
22
22
|
@options = defaults.merge(options)
|
23
|
+
self.source_paths << File.join(root_path, "lib", "dummy_hooks", "templates")
|
23
24
|
self.destination_root = File.join(test_path, name)
|
24
25
|
raise "Invalid directory!" unless Dir.exists?(@root_path)
|
25
26
|
end
|
data/lib/dummier/version.rb
CHANGED
data/test/unit/dummier_test.rb
CHANGED
@@ -36,8 +36,14 @@ class DummierTest < Test::Unit::TestCase
|
|
36
36
|
FileUtils.rm_r(@dummy) if File.exists?(@dummy)
|
37
37
|
assert !File.exists?(@dummy)
|
38
38
|
|
39
|
-
#
|
40
|
-
Dummier::AppGenerator.new(@root)
|
39
|
+
# create a generator
|
40
|
+
@generator = Dummier::AppGenerator.new(@root)
|
41
|
+
|
42
|
+
# make sure our gem's dummy_hooks/templates folder is accessible
|
43
|
+
assert @generator.source_paths.include?(File.join(@root, "lib/dummy_hooks/templates"))
|
44
|
+
|
45
|
+
# run the generator
|
46
|
+
@generator.run!
|
41
47
|
|
42
48
|
# make sure the dummy is created
|
43
49
|
assert File.exists?(@dummy)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dummier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spencer Steffen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-01 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|