railsbuilder 0.1.0 → 0.1.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/railsbuilder.rb +48 -8
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ff889b67b8a58a7da262a03fdf38e9d650cc61
|
4
|
+
data.tar.gz: 35387c44716f8a5a097013b196924ca85d3771f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387f19a35cc271b42ef8f5eca79ca985ef98f1d14cf5f553dcb30da2e3c8f26553692386dab6c135c496566a38ba8ac0bb33bf52acd43ae62bb8517330cb5d26
|
7
|
+
data.tar.gz: 5e8bfa46ad371c3907db5b6a8ef1e40aa1a35f8518d179f5713524b5bf9ef0900f78043937788a5ad35129febc2ddb280cd4f3dfc5c9f212d06ab7b71c004d6f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/railsbuilder.rb
CHANGED
@@ -8,40 +8,72 @@ require 'lineparser'
|
|
8
8
|
|
9
9
|
|
10
10
|
class RailsBuilder
|
11
|
+
|
12
|
+
attr_reader :to_a
|
11
13
|
|
12
14
|
def initialize(filepath=nil)
|
13
15
|
|
14
16
|
buffer = File.read filepath if filepath
|
15
17
|
|
16
18
|
patterns = [
|
19
|
+
[:root, 'app_path: :app_path', :app_path],
|
17
20
|
[:root, 'app: :app', :app],
|
18
21
|
[:root, 'resources: :resources', :resources],
|
19
22
|
[:root, ':resource', :resource],
|
20
23
|
[:resource, 'model', :model],
|
21
24
|
[:model, ':class_name', :model_class],
|
25
|
+
[:resource, 'controller + views', :resource_cv],
|
26
|
+
[:resource_cv, /(\w+)\s+[av]{1,2}/, :resource_cv_av],
|
22
27
|
[:all, /#/]
|
23
28
|
]
|
24
29
|
|
25
|
-
@
|
30
|
+
@to_a = @a = parse(patterns, buffer)
|
26
31
|
end
|
27
32
|
|
28
33
|
def build()
|
29
34
|
|
30
|
-
cols = @
|
35
|
+
cols = @a[:root].select {|x| x[1].has_key? ':app' }
|
31
36
|
@app = cols[0][1][':app']
|
32
37
|
|
33
38
|
unless File.exists? @app then
|
34
39
|
command = 'rails new ' + @app
|
35
40
|
puts ":: preparing to execute shell command: `#{command}`"
|
36
41
|
puts 'Are you sure you want to build a new app? (Y/n)'
|
37
|
-
r = $stdin.getch
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
shell command
|
44
|
+
else
|
45
|
+
Dir.chdir @app
|
46
|
+
end
|
47
|
+
|
48
|
+
# select the :resource records
|
49
|
+
|
50
|
+
@a[:root].select{|x| x[1][":resource"]}.each do |raw_resource|
|
51
|
+
|
52
|
+
resource_child = raw_resource[3][0][3]
|
53
|
+
resource = raw_resource[1][":resource"]
|
54
|
+
|
55
|
+
case resource_child[0][0]
|
56
|
+
|
57
|
+
when :model
|
58
|
+
puts "it's a model"
|
59
|
+
when :resource_cv
|
60
|
+
|
61
|
+
# fetch the action name
|
62
|
+
action = resource_child[0][1][:captures][0]
|
63
|
+
page = action + '.html.erb'
|
64
|
+
|
65
|
+
unless File.exists? File.join('app','views', resource, page) then
|
66
|
+
|
67
|
+
command = "rails generate controller %s %s" % [resource, action]
|
68
|
+
puts ":: preparing to execute shell command: `#{command}`"
|
69
|
+
puts 'Are you sure you want to generate a controller action? (Y/n)'
|
70
|
+
|
71
|
+
shell command
|
72
|
+
end
|
73
|
+
|
43
74
|
end
|
44
75
|
end
|
76
|
+
|
45
77
|
@h
|
46
78
|
end
|
47
79
|
|
@@ -78,6 +110,14 @@ EOF
|
|
78
110
|
a.group_by(&:first)
|
79
111
|
end
|
80
112
|
|
113
|
+
def shell(command)
|
114
|
+
|
115
|
+
if $stdin.getch[/y|\r/i] then
|
116
|
+
IO.popen(command).each_line {|x| print "", x}
|
117
|
+
else
|
118
|
+
puts 'Abort'
|
119
|
+
end
|
120
|
+
end
|
81
121
|
end
|
82
122
|
|
83
123
|
=begin
|
@@ -88,4 +128,4 @@ rb = RailsBuilder.new
|
|
88
128
|
r = rb.build
|
89
129
|
rb.save
|
90
130
|
|
91
|
-
=end
|
131
|
+
=end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
bNcCWso1cJhifoTCytPAyf9YVuyU4HjqC3eqx3p00NCg0VoELwMEkyhkpvYOGz2l
|
32
32
|
NSkTRB6yCN+xzQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-03-
|
34
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
metadata.gz.sig
CHANGED
Binary file
|