survey_generator 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjYzNjlmYjFjYWI5Y2M4MGE2NGU4N2U3YWU4MDRlYTVjMjgzYTMxNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjNmYTljY2M0YzI2ZWQwMDI0MzIyYjQ1YjVkMjc3NDhmMzU4ZmVjMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWQxMmY1MWJmM2M1ZWJkZThmNGNkNmMxZDRmYjI4YzkxMjA0MWYwNzJmNTll
|
10
|
+
YWI3MTdhOGExZWIxMGRhYmMwZjJkNGU5MDk4NWI3YWE4ZWVjNGQ5NTZkYTY2
|
11
|
+
YTM0YTFhYjUxOGIyNzE5MzdlYzhiZmI5YjgxYjBiMDE1MDA5YWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDQ1NzJiZTQxOTBiN2RhZDUyZDBhMDlmYmJmMGI2YmZjMGNlY2IxYjNjMTBi
|
14
|
+
NjhkZWE2NjJhMjU2ZGYzZGU2ZjE2ZjQ5N2ZhYTJlNmJmNzhjNWZmNTRlOTVi
|
15
|
+
ZGQ2N2MyOGMzMTM5MmNlNjYzYWNjYmY5ZDVhOWYwZTA5ODU2ZTc=
|
@@ -8,7 +8,7 @@ class SurveyGenerator < Rails::Generators::Base
|
|
8
8
|
source_root File.expand_path('/templates', __FILE__)
|
9
9
|
|
10
10
|
def generate_survey
|
11
|
-
require Rails.root.to_s + '/gen/
|
11
|
+
require Rails.root.to_s + '/gen/models/survey_model'
|
12
12
|
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new(SurveyMetamodel, Rails.root.to_s)
|
13
13
|
tc.load(File.dirname(__FILE__) + '/templates')
|
14
14
|
tc.expand('main::root', for: MODEL.first)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: survey_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dkemp04
|
@@ -10,23 +10,21 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: A generator for surveys based on model-driven development with RGen.
|
14
14
|
email: dkemp04@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- lib/generators/survey/survey_generator.rb
|
20
|
+
- lib/generators/survey/USAGE
|
19
21
|
- lib/generators/survey/metamodels/survey_metamodel.rb
|
20
|
-
- lib/generators/survey/templates/application/app_template.rb
|
21
|
-
- lib/generators/survey/templates/application/example_app_template.rb
|
22
|
-
- lib/generators/survey/templates/controllers/survey_controller.tpl
|
23
22
|
- lib/generators/survey/templates/main.tpl
|
23
|
+
- lib/generators/survey/templates/controllers/survey_controller.tpl
|
24
24
|
- lib/generators/survey/templates/models/survey_model.tpl
|
25
25
|
- lib/generators/survey/templates/views/survey_form_view.tpl
|
26
26
|
- lib/generators/survey/templates/views/survey_index_view.tpl
|
27
27
|
- lib/generators/survey/templates/views/survey_view.tpl
|
28
|
-
- lib/generators/survey/survey_generator.rb
|
29
|
-
- lib/generators/survey/USAGE
|
30
28
|
homepage: http://rubygems.org/gems/survey_generator
|
31
29
|
licenses: []
|
32
30
|
metadata: {}
|
@@ -49,5 +47,5 @@ rubyforge_project:
|
|
49
47
|
rubygems_version: 2.0.3
|
50
48
|
signing_key:
|
51
49
|
specification_version: 4
|
52
|
-
summary:
|
50
|
+
summary: A generator for surveys based on model-driven development with RGen.
|
53
51
|
test_files: []
|
@@ -1,38 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__) + "../../.."
|
2
|
-
|
3
|
-
require 'survey_generator'
|
4
|
-
|
5
|
-
# >---------------------------------[ Gems ]---------------------------------<
|
6
|
-
|
7
|
-
gem 'survey_generator'
|
8
|
-
gem 'rgen'
|
9
|
-
run 'bundle install'
|
10
|
-
|
11
|
-
# >---------------------------------[ Database ]---------------------------------<
|
12
|
-
|
13
|
-
generate(:model, "Survey", "title:string", "user_id:integer")
|
14
|
-
generate(:model, "Page", "title:string", "number:integer", "questionnary_id:integer")
|
15
|
-
generate(:model, "Field", "name:string", "content:string", "page_id:integer")
|
16
|
-
rake 'db:migrate'
|
17
|
-
|
18
|
-
# >---------------------------------[ Other ]---------------------------------<
|
19
|
-
|
20
|
-
run 'rm public/index.html'
|
21
|
-
generate(:controller, "StaticPages", "home", "help", "about", "contact", "--no-test-framework")
|
22
|
-
route "root to: 'staticPages#home'"
|
23
|
-
|
24
|
-
# >---------------------------------[ MDD ]---------------------------------<
|
25
|
-
|
26
|
-
create_file "gen/models/survey_model.rb", <<-RUBY
|
27
|
-
require 'rgen/model_builder'
|
28
|
-
require 'metamodels/survey_metamodel'
|
29
|
-
|
30
|
-
MODEL = RGen::ModelBuilder.build(SurveyMetamodel) {
|
31
|
-
}
|
32
|
-
RUBY
|
33
|
-
|
34
|
-
# >---------------------------------[ Git ]---------------------------------<
|
35
|
-
|
36
|
-
git :init
|
37
|
-
git add: '.'
|
38
|
-
git commit: '-m "Initial import."'
|
@@ -1,224 +0,0 @@
|
|
1
|
-
# >---------------------------------------------------------------------------<
|
2
|
-
#
|
3
|
-
# _____ _ _ __ ___ _
|
4
|
-
# | __ \ (_) | \ \ / (_) | |
|
5
|
-
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
|
6
|
-
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
|
7
|
-
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
|
8
|
-
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
|
9
|
-
#
|
10
|
-
# This template was generated by RailsWizard, the amazing and awesome Rails
|
11
|
-
# application template builder. Get started at http://railswizard.org
|
12
|
-
#
|
13
|
-
# >---------------------------------------------------------------------------<
|
14
|
-
|
15
|
-
# >----------------------------[ Initial Setup ]------------------------------<
|
16
|
-
|
17
|
-
initializer 'generators.rb', <<-RUBY
|
18
|
-
Rails.application.config.generators do |g|
|
19
|
-
end
|
20
|
-
RUBY
|
21
|
-
|
22
|
-
@recipes = ["activerecord", "capybara", "git", "heroku", "rspec"]
|
23
|
-
|
24
|
-
def recipes; @recipes end
|
25
|
-
def recipe?(name); @recipes.include?(name) end
|
26
|
-
|
27
|
-
def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
|
28
|
-
def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
|
29
|
-
def say_wizard(text); say_custom(@current_recipe || 'wizard', text) end
|
30
|
-
|
31
|
-
def ask_wizard(question)
|
32
|
-
ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m"
|
33
|
-
end
|
34
|
-
|
35
|
-
def yes_wizard?(question)
|
36
|
-
answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
|
37
|
-
case answer.downcase
|
38
|
-
when "yes", "y"
|
39
|
-
true
|
40
|
-
when "no", "n"
|
41
|
-
false
|
42
|
-
else
|
43
|
-
yes_wizard?(question)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def no_wizard?(question); !yes_wizard?(question) end
|
48
|
-
|
49
|
-
def multiple_choice(question, choices)
|
50
|
-
say_custom('question', question)
|
51
|
-
values = {}
|
52
|
-
choices.each_with_index do |choice,i|
|
53
|
-
values[(i + 1).to_s] = choice[1]
|
54
|
-
say_custom (i + 1).to_s + ')', choice[0]
|
55
|
-
end
|
56
|
-
answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
|
57
|
-
values[answer]
|
58
|
-
end
|
59
|
-
|
60
|
-
@current_recipe = nil
|
61
|
-
@configs = {}
|
62
|
-
|
63
|
-
@after_blocks = []
|
64
|
-
def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
|
65
|
-
@after_everything_blocks = []
|
66
|
-
def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
|
67
|
-
@before_configs = {}
|
68
|
-
def before_config(&block); @before_configs[@current_recipe] = block; end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
# >-----------------------------[ ActiveRecord ]------------------------------<
|
73
|
-
|
74
|
-
@current_recipe = "activerecord"
|
75
|
-
@before_configs["activerecord"].call if @before_configs["activerecord"]
|
76
|
-
say_recipe 'ActiveRecord'
|
77
|
-
|
78
|
-
config = {}
|
79
|
-
config['database'] = multiple_choice("Which database are you using?", [["MySQL", "mysql"], ["Oracle", "oracle"], ["PostgreSQL", "postgresql"], ["SQLite", "sqlite3"], ["Frontbase", "frontbase"], ["IBM DB", "ibm_db"]]) if true && true unless config.key?('database')
|
80
|
-
config['auto_create'] = yes_wizard?("Automatically create database with default configuration?") if true && true unless config.key?('auto_create')
|
81
|
-
@configs[@current_recipe] = config
|
82
|
-
|
83
|
-
if config['database']
|
84
|
-
say_wizard "Configuring '#{config['database']}' database settings..."
|
85
|
-
old_gem = gem_for_database
|
86
|
-
@options = @options.dup.merge(:database => config['database'])
|
87
|
-
gsub_file 'Gemfile', "gem '#{old_gem}'", "gem '#{gem_for_database}'"
|
88
|
-
template "config/databases/#{@options[:database]}.yml", "config/database.yml.new"
|
89
|
-
run 'mv config/database.yml.new config/database.yml'
|
90
|
-
end
|
91
|
-
|
92
|
-
after_bundler do
|
93
|
-
rake "db:create:all" if config['auto_create']
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
# >-------------------------------[ Capybara ]--------------------------------<
|
98
|
-
|
99
|
-
@current_recipe = "capybara"
|
100
|
-
@before_configs["capybara"].call if @before_configs["capybara"]
|
101
|
-
say_recipe 'Capybara'
|
102
|
-
|
103
|
-
|
104
|
-
@configs[@current_recipe] = config
|
105
|
-
|
106
|
-
gem 'capybara', :group => [:development, :test]
|
107
|
-
|
108
|
-
after_bundler do
|
109
|
-
create_file "spec/support/capybara.rb", <<-RUBY
|
110
|
-
require 'capybara/rails'
|
111
|
-
require 'capybara/rspec'
|
112
|
-
RUBY
|
113
|
-
|
114
|
-
create_file "spec/requests/home_spec.rb", <<-RUBY
|
115
|
-
require 'spec_helper'
|
116
|
-
|
117
|
-
describe 'visiting the homepage' do
|
118
|
-
before do
|
119
|
-
visit '/'
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should have a body' do
|
123
|
-
page.should have_css('body')
|
124
|
-
end
|
125
|
-
end
|
126
|
-
RUBY
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
# >----------------------------------[ Git ]----------------------------------<
|
131
|
-
|
132
|
-
@current_recipe = "git"
|
133
|
-
@before_configs["git"].call if @before_configs["git"]
|
134
|
-
say_recipe 'Git'
|
135
|
-
|
136
|
-
|
137
|
-
@configs[@current_recipe] = config
|
138
|
-
|
139
|
-
after_everything do
|
140
|
-
git :init
|
141
|
-
git :add => '.'
|
142
|
-
git :commit => '-m "Initial import."'
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
# >--------------------------------[ Heroku ]---------------------------------<
|
147
|
-
|
148
|
-
@current_recipe = "heroku"
|
149
|
-
@before_configs["heroku"].call if @before_configs["heroku"]
|
150
|
-
say_recipe 'Heroku'
|
151
|
-
|
152
|
-
config = {}
|
153
|
-
config['create'] = yes_wizard?("Automatically create appname.heroku.com?") if true && true unless config.key?('create')
|
154
|
-
config['staging'] = yes_wizard?("Create staging app? (appname-staging.heroku.com)") if config['create'] && true unless config.key?('staging')
|
155
|
-
config['domain'] = ask_wizard("Specify custom domain (or leave blank):") if config['create'] && true unless config.key?('domain')
|
156
|
-
config['deploy'] = yes_wizard?("Deploy immediately?") if config['create'] && true unless config.key?('deploy')
|
157
|
-
@configs[@current_recipe] = config
|
158
|
-
|
159
|
-
heroku_name = app_name.gsub('_','')
|
160
|
-
|
161
|
-
after_everything do
|
162
|
-
if config['create']
|
163
|
-
say_wizard "Creating Heroku app '#{heroku_name}.heroku.com'"
|
164
|
-
while !system("heroku create #{heroku_name}")
|
165
|
-
heroku_name = ask_wizard("What do you want to call your app? ")
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
if config['staging']
|
170
|
-
staging_name = "#{heroku_name}-staging"
|
171
|
-
say_wizard "Creating staging Heroku app '#{staging_name}.heroku.com'"
|
172
|
-
while !system("heroku create #{staging_name}")
|
173
|
-
staging_name = ask_wizard("What do you want to call your staging app?")
|
174
|
-
end
|
175
|
-
git :remote => "rm heroku"
|
176
|
-
git :remote => "add production git@heroku.com:#{heroku_name}.git"
|
177
|
-
git :remote => "add staging git@heroku.com:#{staging_name}.git"
|
178
|
-
say_wizard "Created branches 'production' and 'staging' for Heroku deploy."
|
179
|
-
end
|
180
|
-
|
181
|
-
unless config['domain'].blank?
|
182
|
-
run "heroku addons:add custom_domains"
|
183
|
-
run "heroku domains:add #{config['domain']}"
|
184
|
-
end
|
185
|
-
|
186
|
-
git :push => "#{config['staging'] ? 'staging' : 'heroku'} master" if config['deploy']
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
|
-
# >---------------------------------[ RSpec ]---------------------------------<
|
191
|
-
|
192
|
-
@current_recipe = "rspec"
|
193
|
-
@before_configs["rspec"].call if @before_configs["rspec"]
|
194
|
-
say_recipe 'RSpec'
|
195
|
-
|
196
|
-
|
197
|
-
@configs[@current_recipe] = config
|
198
|
-
|
199
|
-
gem 'rspec-rails', '>= 2.0.1', :group => [:development, :test]
|
200
|
-
|
201
|
-
inject_into_file "config/initializers/generators.rb", :after => "Rails.application.config.generators do |g|\n" do
|
202
|
-
" g.test_framework = :rspec\n"
|
203
|
-
end
|
204
|
-
|
205
|
-
after_bundler do
|
206
|
-
generate 'rspec:install'
|
207
|
-
end
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
@current_recipe = nil
|
214
|
-
|
215
|
-
# >-----------------------------[ Run Bundler ]-------------------------------<
|
216
|
-
|
217
|
-
say_wizard "Running Bundler install. This will take a while."
|
218
|
-
run 'bundle install'
|
219
|
-
say_wizard "Running after Bundler callbacks."
|
220
|
-
@after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
|
221
|
-
|
222
|
-
@current_recipe = nil
|
223
|
-
say_wizard "Running after everything callbacks."
|
224
|
-
@after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
|