json_controller_generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +124 -0
- data/README.md +7 -0
- data/Rakefile +11 -0
- data/features/json_controller_generator.feature +13 -0
- data/features/step_definitions/rails_steps.rb +3 -0
- data/features/support/env.rb +7 -0
- data/json_controller_generator.gemspec +25 -0
- data/lib/generators/json_controller_generator.rb +30 -0
- data/lib/generators/templates/controller.rb +13 -0
- metadata +158 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tmp
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
json_controller_generator (0.0.1)
|
5
|
+
rails
|
6
|
+
rspec-rails
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.9)
|
12
|
+
actionpack (= 3.2.9)
|
13
|
+
mail (~> 2.4.4)
|
14
|
+
actionpack (3.2.9)
|
15
|
+
activemodel (= 3.2.9)
|
16
|
+
activesupport (= 3.2.9)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.0)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.9)
|
25
|
+
activesupport (= 3.2.9)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.9)
|
28
|
+
activemodel (= 3.2.9)
|
29
|
+
activesupport (= 3.2.9)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.9)
|
33
|
+
activemodel (= 3.2.9)
|
34
|
+
activesupport (= 3.2.9)
|
35
|
+
activesupport (3.2.9)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
arel (3.0.2)
|
39
|
+
aruba (0.5.1)
|
40
|
+
childprocess (~> 0.3.6)
|
41
|
+
cucumber (>= 1.1.1)
|
42
|
+
rspec-expectations (>= 2.7.0)
|
43
|
+
builder (3.0.4)
|
44
|
+
bump (0.3.6)
|
45
|
+
childprocess (0.3.6)
|
46
|
+
ffi (~> 1.0, >= 1.0.6)
|
47
|
+
cucumber (1.2.1)
|
48
|
+
builder (>= 2.1.2)
|
49
|
+
diff-lcs (>= 1.1.3)
|
50
|
+
gherkin (~> 2.11.0)
|
51
|
+
json (>= 1.4.6)
|
52
|
+
diff-lcs (1.1.3)
|
53
|
+
erubis (2.7.0)
|
54
|
+
ffi (1.2.0)
|
55
|
+
gherkin (2.11.2)
|
56
|
+
json (>= 1.4.6)
|
57
|
+
hike (1.2.1)
|
58
|
+
i18n (0.6.1)
|
59
|
+
journey (1.0.4)
|
60
|
+
json (1.7.5)
|
61
|
+
mail (2.4.4)
|
62
|
+
i18n (>= 0.4.0)
|
63
|
+
mime-types (~> 1.16)
|
64
|
+
treetop (~> 1.4.8)
|
65
|
+
mime-types (1.19)
|
66
|
+
multi_json (1.4.0)
|
67
|
+
polyglot (0.3.3)
|
68
|
+
rack (1.4.1)
|
69
|
+
rack-cache (1.2)
|
70
|
+
rack (>= 0.4)
|
71
|
+
rack-ssl (1.3.2)
|
72
|
+
rack
|
73
|
+
rack-test (0.6.2)
|
74
|
+
rack (>= 1.0)
|
75
|
+
rails (3.2.9)
|
76
|
+
actionmailer (= 3.2.9)
|
77
|
+
actionpack (= 3.2.9)
|
78
|
+
activerecord (= 3.2.9)
|
79
|
+
activeresource (= 3.2.9)
|
80
|
+
activesupport (= 3.2.9)
|
81
|
+
bundler (~> 1.0)
|
82
|
+
railties (= 3.2.9)
|
83
|
+
railties (3.2.9)
|
84
|
+
actionpack (= 3.2.9)
|
85
|
+
activesupport (= 3.2.9)
|
86
|
+
rack-ssl (~> 1.3.2)
|
87
|
+
rake (>= 0.8.7)
|
88
|
+
rdoc (~> 3.4)
|
89
|
+
thor (>= 0.14.6, < 2.0)
|
90
|
+
rake (10.0.2)
|
91
|
+
rdoc (3.12)
|
92
|
+
json (~> 1.4)
|
93
|
+
rspec-core (2.12.1)
|
94
|
+
rspec-expectations (2.12.0)
|
95
|
+
diff-lcs (~> 1.1.3)
|
96
|
+
rspec-mocks (2.12.0)
|
97
|
+
rspec-rails (2.12.0)
|
98
|
+
actionpack (>= 3.0)
|
99
|
+
activesupport (>= 3.0)
|
100
|
+
railties (>= 3.0)
|
101
|
+
rspec-core (~> 2.12.0)
|
102
|
+
rspec-expectations (~> 2.12.0)
|
103
|
+
rspec-mocks (~> 2.12.0)
|
104
|
+
sprockets (2.2.2)
|
105
|
+
hike (~> 1.2)
|
106
|
+
multi_json (~> 1.0)
|
107
|
+
rack (~> 1.0)
|
108
|
+
tilt (~> 1.1, != 1.3.0)
|
109
|
+
thor (0.16.0)
|
110
|
+
tilt (1.3.3)
|
111
|
+
treetop (1.4.12)
|
112
|
+
polyglot
|
113
|
+
polyglot (>= 0.3.1)
|
114
|
+
tzinfo (0.3.35)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
ruby
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
aruba
|
121
|
+
bump
|
122
|
+
cucumber
|
123
|
+
json_controller_generator!
|
124
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# json\_controller\_generator
|
2
|
+
|
3
|
+
A Rails generator for JSON-only controllers
|
4
|
+
|
5
|
+
Create controllers for restful APIs, without generating unwanted helpers, views, and assets.
|
6
|
+
|
7
|
+
[![Build Status](https://secure.travis-ci.org/swipely/json_controller_generator.png?branch=master)](https://travis-ci.org/swipely/json_controller_generator)
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
|
5
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
6
|
+
t.fork = true
|
7
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Run the test suite'
|
11
|
+
task :default => :cucumber
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature:
|
2
|
+
In order to easily generate controllers for a JSON API
|
3
|
+
As a user of Rails3 and json_controller_generator
|
4
|
+
I would like to use json_controller_generator generators.
|
5
|
+
|
6
|
+
Scenario: The json_controller_generator generators create a controller with specs
|
7
|
+
When I successfully run `bundle exec rails new testapp`
|
8
|
+
And I cd to "testapp"
|
9
|
+
And I add "json_controller_generator" from this project as a dependency
|
10
|
+
When I successfully run `bundle install`
|
11
|
+
And I successfully run `bundle exec rails generate json_controller posts index`
|
12
|
+
Then the output should contain "app/controllers/posts_controller.rb"
|
13
|
+
And the file "app/controllers/posts_controller.rb" should contain "def index"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.authors = ["Matt Gillooly"]
|
3
|
+
gem.email = ["matt@swipely.com"]
|
4
|
+
gem.summary = %q{A Rails generator for JSON-only controllers}
|
5
|
+
gem.description = %q{Create controllers for restful APIs, without generating unwanted helpers, views, and assets.}
|
6
|
+
gem.homepage = "https://github.com/swipely/json_controller_generator"
|
7
|
+
|
8
|
+
gem.files = `git ls-files`.split($\)
|
9
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
10
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
11
|
+
gem.require_path = "lib"
|
12
|
+
|
13
|
+
gem.name = "json_controller_generator"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
|
16
|
+
gem.version = "0.0.1"
|
17
|
+
|
18
|
+
gem.add_dependency('rails')
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency 'cucumber'
|
22
|
+
gem.add_development_dependency 'bump'
|
23
|
+
gem.add_development_dependency 'aruba'
|
24
|
+
gem.add_dependency 'rspec-rails'
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'generators/rspec'
|
2
|
+
|
3
|
+
class JsonControllerGenerator < Rails::Generators::NamedBase
|
4
|
+
desc <<EOF
|
5
|
+
Stubs out a new controller with no views, assets, or helpers. Pass the
|
6
|
+
controller name, either CamelCased or under_scored, and a list of actions
|
7
|
+
as arguments.
|
8
|
+
|
9
|
+
To create a controller within a module, specify the controller name as a
|
10
|
+
path like 'parent_module/controller_name'.
|
11
|
+
|
12
|
+
This generates a controller class in app/controllers test framework generators.
|
13
|
+
EOF
|
14
|
+
|
15
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
16
|
+
check_class_collision :suffix => "Controller"
|
17
|
+
source_root File.expand_path("../templates", __FILE__)
|
18
|
+
|
19
|
+
def create_controller_files
|
20
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_routes
|
24
|
+
actions.reverse.each do |action|
|
25
|
+
route %{get "#{file_name}/#{action}"}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
hook_for :test_framework, :as => :controller
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: json_controller_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matt Gillooly
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: cucumber
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bump
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: aruba
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Create controllers for restful APIs, without generating unwanted helpers,
|
111
|
+
views, and assets.
|
112
|
+
email:
|
113
|
+
- matt@swipely.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- features/json_controller_generator.feature
|
125
|
+
- features/step_definitions/rails_steps.rb
|
126
|
+
- features/support/env.rb
|
127
|
+
- json_controller_generator.gemspec
|
128
|
+
- lib/generators/json_controller_generator.rb
|
129
|
+
- lib/generators/templates/controller.rb
|
130
|
+
homepage: https://github.com/swipely/json_controller_generator
|
131
|
+
licenses: []
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.8.24
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: A Rails generator for JSON-only controllers
|
154
|
+
test_files:
|
155
|
+
- features/json_controller_generator.feature
|
156
|
+
- features/step_definitions/rails_steps.rb
|
157
|
+
- features/support/env.rb
|
158
|
+
has_rdoc:
|