rapid-core 0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +35 -2
- data/Rakefile +77 -48
- data/doc/server.txt +15 -0
- data/features/settings/double-nested/default.feature +2 -2
- data/features/settings/double-nested/validates/presence_of.feature +1 -1
- data/features/settings/nested/default.feature +1 -1
- data/features/settings/nested/validates/presence_of.feature +1 -1
- data/features/settings/not_found.feature +2 -2
- data/features/step_definitions/settings_steps.rb +7 -3
- data/features/step_definitions/template_steps.rb +3 -1
- data/lib/rapid/check.rb +30 -23
- data/lib/rapid/core.rb +12 -0
- data/lib/rapid/error.rb +1 -0
- data/lib/rapid/module.rb +10 -1
- data/lib/rapid/railtie.rb +6 -0
- data/lib/rapid/setting/base.rb +31 -8
- data/lib/rapid/setting/boolean_setting.rb +20 -1
- data/lib/rapid/setting/definer.rb +11 -47
- data/lib/rapid/setting/integer_setting.rb +7 -7
- data/lib/rapid/setting/module.rb +56 -0
- data/lib/rapid/setting/namespace/base.rb +35 -60
- data/lib/rapid/setting/namespace/instance.rb +195 -28
- data/lib/rapid/setting/string_setting.rb +7 -1
- data/lib/rapid/settings.rb +51 -65
- data/lib/rapid/skeleton/base.rb +39 -18
- data/lib/rapid/skeleton/helpers/directory.rb +5 -6
- data/lib/rapid/skeleton/helpers/files.rb +62 -0
- data/lib/rapid/skeleton/helpers/gem.rb +43 -32
- data/lib/rapid/skeleton/helpers/if_setting.rb +44 -0
- data/lib/rapid/skeleton/helpers/migration.rb +102 -32
- data/lib/rapid/skeleton/helpers/route.rb +8 -12
- data/lib/rapid/skeleton/helpers/script.rb +1 -2
- data/lib/rapid/skeleton/helpers/template.rb +23 -25
- data/lib/rapid/skeleton/helpers/view.rb +7 -7
- data/lib/rapid/spec/template.rb +1 -1
- data/lib/rapid/version.rb +1 -1
- data/lib/rapid/web/base.rb +35 -0
- data/lib/rapid/web/bootstrap.rb +98 -0
- data/lib/rapid/web/controller_helpers.rb +60 -0
- data/lib/rapid/web/navigator.rb +18 -0
- data/lib/rapid/web/select_helpers.rb +63 -0
- data/lib/rapid/web/settings_form_builder.rb +205 -0
- data/lib/rapid/web/static_helpers.rb +28 -0
- data/lib/rapid/web/tasks.rb +10 -0
- data/public/rapid/core/bootstrap-collapse.js +136 -0
- data/public/rapid/core/bootstrap-responsive.min.css +3 -0
- data/public/rapid/core/bootstrap.min.css +556 -0
- data/public/rapid/core/jquery-1.7.1.js +9253 -0
- data/public/rapid/core/prettify.css +30 -0
- data/public/rapid/core/prettify.js +28 -0
- data/rapid-core.gemspec +5 -0
- data/spec/rapid/check_spec.rb +11 -4
- data/spec/rapid/module_spec.rb +18 -0
- data/spec/rapid/setting/base_spec.rb +71 -0
- data/spec/rapid/setting/boolean_setting_spec.rb +95 -0
- data/spec/rapid/setting/definer_spec.rb +7 -13
- data/spec/rapid/setting/integer_setting_spec.rb +49 -0
- data/spec/rapid/setting/module_spec.rb +25 -0
- data/spec/rapid/setting/namespace/base_spec.rb +88 -54
- data/spec/rapid/setting/namespace/instance_spec.rb +308 -5
- data/spec/rapid/setting/string_setting_spec.rb +43 -0
- data/spec/rapid/settings_spec.rb +65 -17
- data/spec/rapid/skeleton/base_spec.rb +113 -7
- data/spec/rapid/skeleton/helpers/directory_spec.rb +8 -6
- data/spec/rapid/skeleton/helpers/files_spec.rb +93 -0
- data/spec/rapid/skeleton/helpers/gem_spec.rb +65 -36
- data/spec/rapid/skeleton/helpers/if_setting_spec.rb +110 -0
- data/spec/rapid/skeleton/helpers/migration_spec.rb +190 -1
- data/spec/rapid/skeleton/helpers/route_spec.rb +13 -12
- data/spec/rapid/skeleton/helpers/script_spec.rb +2 -1
- data/spec/rapid/skeleton/helpers/template_spec.rb +22 -35
- data/spec/rapid/spec/template_spec.rb +1 -1
- data/spec/rapid/web/base_spec.rb +33 -0
- data/spec/rapid/web/bootstrap_spec.rb +72 -0
- data/spec/rapid/web/controller_helpers_spec.rb +86 -0
- data/spec/rapid/web/navigator_spec.rb +17 -0
- data/spec/rapid/web/select_helpers_spec.rb +71 -0
- data/spec/rapid/web/settings_form_builder_spec.rb +255 -0
- data/spec/rapid/web/static_helpers_spec.rb +26 -0
- data/spec/spec_helper.rb +3 -0
- data/views/index.erb +11 -0
- data/views/layout.erb +9 -0
- metadata +107 -12
- data/lib/rapid.rb +0 -37
- data/lib/rapid/setting/class_hash.rb +0 -34
- data/lib/rapid/setting/instance_hash.rb +0 -132
- data/lib/rapid/setting/instance_root.rb +0 -107
- data/spec/rapid/setting/instance_root_spec.rb +0 -161
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rapid-core (0.
|
4
|
+
rapid-core (0.2)
|
5
5
|
activemodel (>= 3.0)
|
6
6
|
activesupport (>= 3.0)
|
7
7
|
erubis
|
8
8
|
i18n
|
9
|
+
sinatra
|
10
|
+
sinatra_more
|
11
|
+
tzinfo
|
9
12
|
|
10
13
|
GEM
|
11
14
|
remote: http://rubygems.org/
|
@@ -16,6 +19,7 @@ GEM
|
|
16
19
|
activesupport (3.2.1)
|
17
20
|
i18n (~> 0.6)
|
18
21
|
multi_json (~> 1.0)
|
22
|
+
backports (2.3.0)
|
19
23
|
builder (3.0.0)
|
20
24
|
cucumber (1.1.4)
|
21
25
|
builder (>= 2.1.2)
|
@@ -25,11 +29,17 @@ GEM
|
|
25
29
|
term-ansicolor (>= 1.0.6)
|
26
30
|
diff-lcs (1.1.3)
|
27
31
|
erubis (2.7.0)
|
32
|
+
eventmachine (0.12.10)
|
28
33
|
gherkin (2.7.4)
|
29
34
|
json (>= 1.4.6)
|
30
35
|
i18n (0.6.0)
|
31
36
|
json (1.6.5)
|
32
|
-
multi_json (1.0
|
37
|
+
multi_json (1.1.0)
|
38
|
+
rack (1.4.1)
|
39
|
+
rack-protection (1.2.0)
|
40
|
+
rack
|
41
|
+
rack-test (0.6.1)
|
42
|
+
rack (>= 1.0)
|
33
43
|
rake (0.9.2.2)
|
34
44
|
rcov (0.9.9)
|
35
45
|
rspec (2.5.0)
|
@@ -40,7 +50,29 @@ GEM
|
|
40
50
|
rspec-expectations (2.5.0)
|
41
51
|
diff-lcs (~> 1.1.2)
|
42
52
|
rspec-mocks (2.5.0)
|
53
|
+
sinatra (1.3.2)
|
54
|
+
rack (~> 1.3, >= 1.3.6)
|
55
|
+
rack-protection (~> 1.2)
|
56
|
+
tilt (~> 1.3, >= 1.3.3)
|
57
|
+
sinatra-contrib (1.3.1)
|
58
|
+
backports (>= 2.0)
|
59
|
+
eventmachine
|
60
|
+
rack-protection
|
61
|
+
rack-test
|
62
|
+
sinatra (~> 1.3.0)
|
63
|
+
tilt (~> 1.3)
|
64
|
+
sinatra-reloader (1.0)
|
65
|
+
sinatra-contrib
|
66
|
+
sinatra_more (0.3.43)
|
67
|
+
activesupport
|
68
|
+
bundler (>= 0.9.2)
|
69
|
+
sinatra (>= 0.9.2)
|
70
|
+
thor (>= 0.11.8)
|
71
|
+
tilt (>= 0.2)
|
43
72
|
term-ansicolor (1.0.7)
|
73
|
+
thor (0.14.6)
|
74
|
+
tilt (1.3.3)
|
75
|
+
tzinfo (0.3.31)
|
44
76
|
|
45
77
|
PLATFORMS
|
46
78
|
ruby
|
@@ -51,3 +83,4 @@ DEPENDENCIES
|
|
51
83
|
rapid-core!
|
52
84
|
rcov
|
53
85
|
rspec
|
86
|
+
sinatra-reloader
|
data/Rakefile
CHANGED
@@ -1,61 +1,90 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require 'rapid/web/tasks'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
desc "Run the Sinatra server to edit your application with this gem"
|
5
|
+
task :server do
|
6
|
+
path = ENV["APP"]
|
7
|
+
raise "USAGE: rake server APP=/path/to/rails/application" if path.nil?
|
8
|
+
|
9
|
+
require 'rapid/core'
|
10
|
+
Rapid::Web::Navigator.run!
|
11
|
+
end
|
5
12
|
|
6
|
-
|
13
|
+
begin
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
@rspec = true
|
16
|
+
rescue ScriptError
|
17
|
+
puts "Warning: Can't test because RSpec is not installed. Try 'bundle install'"
|
18
|
+
end
|
7
19
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
20
|
+
begin
|
21
|
+
require 'cucumber/rake/task'
|
22
|
+
@cucumber = true
|
23
|
+
rescue ScriptError
|
24
|
+
puts "Warning: Can't test because Cucumber is not installed. Try 'bundle install'"
|
25
|
+
end
|
14
26
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
t.profile = 'wip'
|
19
|
-
end
|
27
|
+
if @rspec
|
28
|
+
RSpec::Core::RakeTask.new('spec')
|
29
|
+
end
|
20
30
|
|
21
|
-
|
22
|
-
# t.binary = vendored_cucumber_bin
|
23
|
-
t.fork = true # You may get faster startup if you set this to false
|
24
|
-
t.profile = 'rerun'
|
25
|
-
end
|
31
|
+
if @cucumber
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
namespace :cucumber do
|
34
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
|
35
|
+
# t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
36
|
+
t.fork = true # You may get faster startup if you set this to false
|
37
|
+
t.profile = 'default'
|
38
|
+
end
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
41
|
+
# t.binary = vendored_cucumber_bin
|
42
|
+
t.fork = true # You may get faster startup if you set this to false
|
43
|
+
t.profile = 'wip'
|
44
|
+
end
|
45
|
+
|
46
|
+
Cucumber::Rake::Task.new(:rerun, 'Record failing features and run only them if any exist') do |t|
|
47
|
+
# t.binary = vendored_cucumber_bin
|
48
|
+
t.fork = true # You may get faster startup if you set this to false
|
49
|
+
t.profile = 'rerun'
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'Run all features'
|
53
|
+
task :all => [:ok, :wip]
|
42
54
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
55
|
+
desc 'Alias for cucumber:ok'
|
56
|
+
task :cucumber => 'cucumber:ok'
|
57
|
+
end
|
58
|
+
|
59
|
+
if @rspec && @cucumber
|
60
|
+
namespace :rcov do
|
61
|
+
|
62
|
+
rcov_opts = '--exclude osx\/objc,cucumber.rb,cucumber\/,gems\/,spec\/,features\/ --aggregate coverage.data'
|
63
|
+
|
64
|
+
desc "Run all specs with rcov"
|
65
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
66
|
+
t.rcov = true
|
67
|
+
t.pattern = "./spec/**/*_spec.rb"
|
68
|
+
t.rcov_opts = rcov_opts
|
69
|
+
end
|
70
|
+
|
71
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features and produce a coverage report') do |t|
|
72
|
+
# t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
73
|
+
t.fork = true # You may get faster startup if you set this to false
|
74
|
+
t.profile = 'default'
|
75
|
+
t.rcov = true
|
76
|
+
t.rcov_opts = "#{rcov_opts} --failure-threshold 100"
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Run specs and features and produce a coverage report"
|
80
|
+
task :all do
|
81
|
+
rm "coverage.data" if File.exist?("coverage.data")
|
82
|
+
Rake::Task['rcov:spec'].invoke
|
83
|
+
Rake::Task["rcov:cucumber"].invoke
|
84
|
+
end
|
85
|
+
|
50
86
|
end
|
51
87
|
|
52
|
-
|
53
|
-
task :all do
|
54
|
-
rm "coverage.data" if File.exist?("coverage.data")
|
55
|
-
Rake::Task['rcov:spec'].invoke
|
56
|
-
Rake::Task["rcov:cucumber"].invoke
|
57
|
-
end
|
88
|
+
task :ci => 'rcov:all'
|
58
89
|
|
59
90
|
end
|
60
|
-
|
61
|
-
task :ci => 'rcov:all'
|
data/doc/server.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
* respond under /rapid
|
2
|
+
|
3
|
+
* /rapid lists all the possible children apps
|
4
|
+
|
5
|
+
* /rapid/X by default
|
6
|
+
* UI for editing settings (pull settings for default values)
|
7
|
+
* Submit pushes the changes to the application
|
8
|
+
|
9
|
+
* each gem can customize its behavior by providing its own sinatra app
|
10
|
+
|
11
|
+
* sinatra apps can run on their own
|
12
|
+
* sinatra apps can run inside the rails app it's modifying
|
13
|
+
|
14
|
+
* everything under /rapid shares a layout by default
|
15
|
+
|
@@ -40,11 +40,11 @@ Feature: Default double nesting
|
|
40
40
|
app.author.name:
|
41
41
|
"""
|
42
42
|
Then I should be good
|
43
|
-
And vice versa
|
43
|
+
# And vice versa
|
44
44
|
|
45
45
|
Scenario: integer value
|
46
46
|
When I load:
|
47
47
|
"""
|
48
48
|
app.author: 1
|
49
49
|
"""
|
50
|
-
Then "app.author" should have a "doesn't allow values of that type" error
|
50
|
+
Then "app.author" should have a "doesn't allow values of that type" error
|
@@ -23,11 +23,11 @@ Feature: Settings handling not found cases
|
|
23
23
|
"""
|
24
24
|
app.author: Dan
|
25
25
|
"""
|
26
|
-
Then "app" should have a "can't be found" error
|
26
|
+
Then "app.author" should have a "can't be found" error
|
27
27
|
|
28
28
|
Scenario: Incorrectly treating a setting is a namespace
|
29
29
|
When I load:
|
30
30
|
"""
|
31
31
|
name.version: 1.0
|
32
32
|
"""
|
33
|
-
Then "name" should have a "doesn't allow values of that type" error
|
33
|
+
Then "name.version" should have a "doesn't allow values of that type" error
|
@@ -44,7 +44,9 @@ end
|
|
44
44
|
When /^I load:$/ do |yaml_content|
|
45
45
|
@current_yaml = yaml_content
|
46
46
|
@current_settings = @current_settings_class.new
|
47
|
-
|
47
|
+
|
48
|
+
hash = YAML.load(yaml_content)
|
49
|
+
@current_settings.load hash if hash
|
48
50
|
end
|
49
51
|
|
50
52
|
Then /^I should be good$/ do
|
@@ -71,8 +73,10 @@ end
|
|
71
73
|
|
72
74
|
Then /^vice versa$/ do
|
73
75
|
if @current_yaml && @current_settings
|
74
|
-
|
75
|
-
|
76
|
+
hash = @current_settings.settings.to_dot_hash
|
77
|
+
expected_hash = YAML.load(@current_yaml) || {}
|
78
|
+
|
79
|
+
hash.should == expected_hash
|
76
80
|
|
77
81
|
elsif @current_template
|
78
82
|
original_settings = @current_settings
|
@@ -28,7 +28,9 @@ When /^I push the skeleton through "([^\"]*)" with:$/ do |template_filename, set
|
|
28
28
|
@current_template = find_template template_filename
|
29
29
|
|
30
30
|
@current_yaml = settings_content
|
31
|
-
|
31
|
+
|
32
|
+
hash = YAML.load settings_content
|
33
|
+
@current_skeleton.settings = hash if hash
|
32
34
|
|
33
35
|
@current_template_content = @current_template.push @current_skeleton
|
34
36
|
end
|
data/lib/rapid/check.rb
CHANGED
@@ -3,10 +3,11 @@ module Rapid
|
|
3
3
|
class Check
|
4
4
|
|
5
5
|
attr_reader :code, :ok_count, :warning_count, :error_count
|
6
|
+
attr_accessor :console
|
6
7
|
|
7
8
|
def initialize code, options = {}
|
8
9
|
@code = code
|
9
|
-
@
|
10
|
+
@console = options[:console]
|
10
11
|
@ok_count = 0
|
11
12
|
@warning_count = 0
|
12
13
|
@error_count = 0
|
@@ -60,11 +61,22 @@ module Rapid
|
|
60
61
|
log :error, "", ""
|
61
62
|
end
|
62
63
|
|
64
|
+
def log_value log_type, key, value
|
65
|
+
return unless @console
|
66
|
+
|
67
|
+
# don't print out very large strings
|
68
|
+
if value.is_a?(String) && value.length > 50
|
69
|
+
value = value[0..23] + "..." + value[value.length - 23..-1]
|
70
|
+
end
|
71
|
+
|
72
|
+
log log_type, " #{key}:", value.inspect
|
73
|
+
end
|
74
|
+
|
63
75
|
def with_section name
|
64
|
-
puts "" if @sections.empty?
|
76
|
+
puts "" if @sections.empty? && @console
|
65
77
|
|
66
78
|
indention = " " * @sections.length
|
67
|
-
puts "#{indention}#{name}"
|
79
|
+
puts "#{indention}#{name}" if @console
|
68
80
|
|
69
81
|
@sections.push name
|
70
82
|
yield
|
@@ -72,6 +84,20 @@ module Rapid
|
|
72
84
|
@sections.pop
|
73
85
|
end
|
74
86
|
|
87
|
+
def as_current
|
88
|
+
self.class.current = self
|
89
|
+
yield
|
90
|
+
|
91
|
+
ensure
|
92
|
+
self.class.current = nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def encounters_error?
|
96
|
+
old_count = self.error_count
|
97
|
+
yield
|
98
|
+
old_count != self.error_count
|
99
|
+
end
|
100
|
+
|
75
101
|
protected
|
76
102
|
|
77
103
|
def clean_hash hash
|
@@ -97,7 +123,7 @@ module Rapid
|
|
97
123
|
end
|
98
124
|
|
99
125
|
def log type, filename, message
|
100
|
-
return unless @
|
126
|
+
return unless @console
|
101
127
|
|
102
128
|
indention = " " * @sections.length
|
103
129
|
|
@@ -105,14 +131,6 @@ module Rapid
|
|
105
131
|
Rapid.color_puts type, output
|
106
132
|
end
|
107
133
|
|
108
|
-
def as_current
|
109
|
-
self.class.current = self
|
110
|
-
yield
|
111
|
-
|
112
|
-
ensure
|
113
|
-
self.class.current = nil
|
114
|
-
end
|
115
|
-
|
116
134
|
class << self
|
117
135
|
attr_accessor :current, :file
|
118
136
|
|
@@ -144,17 +162,6 @@ module Rapid
|
|
144
162
|
new code, *args
|
145
163
|
end
|
146
164
|
|
147
|
-
def encounters_error?
|
148
|
-
if current.nil?
|
149
|
-
yield
|
150
|
-
false
|
151
|
-
else
|
152
|
-
old_count = current.error_count
|
153
|
-
yield
|
154
|
-
old_count != current.error_count
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
165
|
end
|
159
166
|
|
160
167
|
end
|
data/lib/rapid/core.rb
CHANGED
@@ -11,6 +11,8 @@ require "rapid/module"
|
|
11
11
|
require "rapid/settings"
|
12
12
|
require "rapid/check"
|
13
13
|
|
14
|
+
require "rapid/skeleton/helpers/if_setting"
|
15
|
+
require "rapid/skeleton/helpers/files"
|
14
16
|
require "rapid/skeleton/helpers/directory"
|
15
17
|
require "rapid/skeleton/helpers/gem"
|
16
18
|
require "rapid/skeleton/helpers/migration"
|
@@ -34,4 +36,14 @@ require "rapid/template/node/variable"
|
|
34
36
|
require "rapid/template/node/if_node"
|
35
37
|
require "rapid/template/node/comment_node"
|
36
38
|
|
39
|
+
require 'sinatra'
|
40
|
+
require 'sinatra_more/markup_plugin'
|
41
|
+
require 'rapid/web/select_helpers'
|
42
|
+
require 'rapid/web/settings_form_builder'
|
43
|
+
require 'rapid/web/controller_helpers'
|
44
|
+
require 'rapid/web/static_helpers'
|
45
|
+
require 'rapid/web/bootstrap'
|
46
|
+
require 'rapid/web/base'
|
47
|
+
require 'rapid/web/navigator'
|
48
|
+
|
37
49
|
require 'rapid/railtie' if defined? Rails
|