railsbuilder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c6a33a0a354b43ceab08297355bde21fc365925
4
+ data.tar.gz: 6c513bb65eca3e8847748b467a544c7285ad28ae
5
+ SHA512:
6
+ metadata.gz: a65a78db65efc5d58f9ba253841b37c5539afbcbe716c71e6b18096af042c47c6522b07f30d97d36f47610245cefccce0a417e2c3403919921b3d6a8251923bc
7
+ data.tar.gz: 7a634beda2d9e7ae152d96b83257cd44a992a6658de5d910ed5717e1216cbc75f8b5f101ca0e4ae681660d450acab11dc5492fa163e31d0180365ac4fc8a2bc8
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: railsbuilder.rb
4
+
5
+ require 'fileutils'
6
+ require 'io/console'
7
+ require 'lineparser'
8
+
9
+
10
+ class RailsBuilder
11
+
12
+ def initialize(filepath=nil)
13
+
14
+ buffer = File.read filepath if filepath
15
+
16
+ patterns = [
17
+ [:root, 'app: :app', :app],
18
+ [:root, 'resources: :resources', :resources],
19
+ [:root, ':resource', :resource],
20
+ [:resource, 'model', :model],
21
+ [:model, ':class_name', :model_class],
22
+ [:all, /#/]
23
+ ]
24
+
25
+ @h = parse(patterns, buffer)
26
+ end
27
+
28
+ def build()
29
+
30
+ cols = @h[:root].select {|x| x[1].has_key? ':app' }
31
+ @app = cols[0][1][':app']
32
+
33
+ unless File.exists? @app then
34
+ command = 'rails new ' + @app
35
+ puts ":: preparing to execute shell command: `#{command}`"
36
+ puts 'Are you sure you want to build a new app? (Y/n)'
37
+ r = $stdin.getch
38
+
39
+ if r[/y|\r/i] then
40
+ IO.popen(command).each_line {|x| print "", x}
41
+ else
42
+ puts 'Abort'
43
+ end
44
+ end
45
+ @h
46
+ end
47
+
48
+ def save()
49
+ File.write "#{@app}.cfg", @config
50
+ end
51
+
52
+ private
53
+
54
+ def parse(patterns, s=nil)
55
+
56
+ if s.nil? then
57
+
58
+ # is there a directory called site1?
59
+
60
+ dir = 'site1'
61
+
62
+ while File.exists? dir do
63
+ i = dir.slice!(/\d+$/).to_i; dir += (i+=1).to_s
64
+ end
65
+
66
+
67
+ s =<<EOF
68
+ #
69
+ # railsbuilder configuration file
70
+ #
71
+ app: #{dir}
72
+
73
+ # resources: posts
74
+ EOF
75
+ end
76
+ @config = s
77
+ a = LineParser.new(patterns).parse s
78
+ a.group_by(&:first)
79
+ end
80
+
81
+ end
82
+
83
+ =begin
84
+
85
+ # basic example
86
+
87
+ rb = RailsBuilder.new
88
+ r = rb.build
89
+ rb.save
90
+
91
+ =end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railsbuilder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE0MDMwOTIxMDcwMFoXDTE1MDMwOTIxMDcwMFowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAMhEv1KfLSF8oAjs6AfAh7Mycbt4kjMKPAYFLlQWyCrN1eFPQJEftqM4bJeY
19
+ HxoMhHJUPU3CM0JXXe/rVw3SWrNQeclli2jwOIYvdlEyIj0styctMMmMOE4MCMJk
20
+ //C2ZKB+tfN4+PvM5aYh076zp/0nnZrqLDKYuqKi0ymAaTEvaxbbi08A9OK+bBDz
21
+ nhsOeaOxb3BVVK6s+WjoJi6aeyhZta/uPQ0hmQSuClbSLrJWUkEI2u68UvJX9Lh+
22
+ hY7rEIOuSvnxG6TXOGeXWYDd8dZ4ZQTP5eE0ewieEXCbZm3JNt4zX94vXxnEydv4
23
+ q7ecLQPESY+gfXKm8IJDjBQHhb0CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUS3H611aOQ4MXksEN8dyPFeFAFsUwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAEgkiAR6Q
27
+ TREhihguYpDtbZ73U7n3Lyb3W6O7JbkKso32E5e9Y4kpYDyXfqaZWtqsim0tFVKr
28
+ s7cY5xCCb2KJuq9trdL/YE8pS6FBYRwGRJRtSXIztJa307ucLsbEg7yZosOYHVPa
29
+ 9ORUL7Iglk+myld0LJPkJyjBcqFPpybyUsIovQCwsN8BBtGxjQo41nP2+3Tx46yF
30
+ CsyTkuMlSA8Os5No6RCS1GZTPwp3F4j2qZcS/YAsStir8dfqV0qXPfjxmsg8SNwM
31
+ bNcCWso1cJhifoTCytPAyf9YVuyU4HjqC3eqx3p00NCg0VoELwMEkyhkpvYOGz2l
32
+ NSkTRB6yCN+xzQ==
33
+ -----END CERTIFICATE-----
34
+ date: 2014-03-09 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ - !ruby/object:Gem::Dependency
51
+ name: lineparser
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ description:
65
+ email: james@r0bertson.co.uk
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - lib/railsbuilder.rb
71
+ homepage: https://github.com/jrobertson/railsbuilder
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.14
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Builds a Rails app from a configuration file.
95
+ test_files: []
metadata.gz.sig ADDED
Binary file