rails_packager 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +34 -0
  4. data/exe/rails_package +25 -0
  5. data/lib/rails_packager.rb +8 -0
  6. data/lib/rails_packager/command.rb +84 -0
  7. data/lib/rails_packager/command_parser.rb +66 -0
  8. data/lib/rails_packager/engine.rb +4 -0
  9. data/lib/rails_packager/runner.rb +138 -0
  10. data/lib/rails_packager/util.rb +30 -0
  11. data/lib/rails_packager/version.rb +3 -0
  12. data/lib/tasks/rails_packager_tasks.rake +8 -0
  13. data/test/dummy/Gemfile +2 -0
  14. data/test/dummy/README.rdoc +28 -0
  15. data/test/dummy/Rakefile +6 -0
  16. data/test/dummy/app/assets/javascripts/application.js +13 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  18. data/test/dummy/app/controllers/application_controller.rb +5 -0
  19. data/test/dummy/app/helpers/application_helper.rb +2 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy/bin/bundle +3 -0
  22. data/test/dummy/bin/rails +4 -0
  23. data/test/dummy/bin/rake +4 -0
  24. data/test/dummy/bin/setup +29 -0
  25. data/test/dummy/config.ru +4 -0
  26. data/test/dummy/config/application.rb +22 -0
  27. data/test/dummy/config/boot.rb +5 -0
  28. data/test/dummy/config/database.yml +25 -0
  29. data/test/dummy/config/environment.rb +5 -0
  30. data/test/dummy/config/environments/development.rb +41 -0
  31. data/test/dummy/config/environments/production.rb +79 -0
  32. data/test/dummy/config/environments/test.rb +42 -0
  33. data/test/dummy/config/initializers/assets.rb +11 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  36. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/test/dummy/config/initializers/inflections.rb +16 -0
  38. data/test/dummy/config/initializers/mime_types.rb +4 -0
  39. data/test/dummy/config/initializers/session_store.rb +3 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +56 -0
  43. data/test/dummy/config/secrets.yml +22 -0
  44. data/test/dummy/db/development.sqlite3 +0 -0
  45. data/test/dummy/db/schema.rb +15 -0
  46. data/test/dummy/db/test.sqlite3 +0 -0
  47. data/test/dummy/log/development.log +7 -0
  48. data/test/dummy/log/test.log +21747 -0
  49. data/test/dummy/public/404.html +67 -0
  50. data/test/dummy/public/422.html +67 -0
  51. data/test/dummy/public/500.html +66 -0
  52. data/test/dummy/public/favicon.ico +0 -0
  53. data/test/files/environment-variable-in-one-command-merges-with-env.yml +9 -0
  54. data/test/files/environment-variable-in-one-command.yml +5 -0
  55. data/test/files/environment-variable-replacement.yml +7 -0
  56. data/test/files/execution-path.yml +3 -0
  57. data/test/files/failure-integration.yml +6 -0
  58. data/test/files/files-is-within-quotes.yml +2 -0
  59. data/test/files/files-not-its-own-argument.yml +2 -0
  60. data/test/files/fully-customized.yml +13 -0
  61. data/test/files/missing-command-name.yml +5 -0
  62. data/test/files/quotes-in-command.yml +2 -0
  63. data/test/files/simple-integration.yml +7 -0
  64. data/test/integration_test.rb +224 -0
  65. data/test/jruby_dummy/Jarfile +1 -0
  66. data/test/jruby_dummy/README.rdoc +28 -0
  67. data/test/jruby_dummy/Rakefile +6 -0
  68. data/test/jruby_dummy/app/assets/javascripts/application.js +13 -0
  69. data/test/jruby_dummy/app/assets/stylesheets/application.css +15 -0
  70. data/test/jruby_dummy/app/controllers/application_controller.rb +5 -0
  71. data/test/jruby_dummy/app/helpers/application_helper.rb +2 -0
  72. data/test/jruby_dummy/app/views/layouts/application.html.erb +14 -0
  73. data/test/jruby_dummy/bin/bundle +3 -0
  74. data/test/jruby_dummy/bin/rails +4 -0
  75. data/test/jruby_dummy/bin/rake +4 -0
  76. data/test/jruby_dummy/bin/setup +29 -0
  77. data/test/jruby_dummy/config.ru +4 -0
  78. data/test/jruby_dummy/config/application.rb +22 -0
  79. data/test/jruby_dummy/config/boot.rb +5 -0
  80. data/test/jruby_dummy/config/database.yml +23 -0
  81. data/test/jruby_dummy/config/environment.rb +5 -0
  82. data/test/jruby_dummy/config/environments/development.rb +41 -0
  83. data/test/jruby_dummy/config/environments/production.rb +79 -0
  84. data/test/jruby_dummy/config/environments/test.rb +42 -0
  85. data/test/jruby_dummy/config/initializers/assets.rb +11 -0
  86. data/test/jruby_dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/jruby_dummy/config/initializers/cookies_serializer.rb +3 -0
  88. data/test/jruby_dummy/config/initializers/filter_parameter_logging.rb +4 -0
  89. data/test/jruby_dummy/config/initializers/inflections.rb +16 -0
  90. data/test/jruby_dummy/config/initializers/mime_types.rb +4 -0
  91. data/test/jruby_dummy/config/initializers/session_store.rb +3 -0
  92. data/test/jruby_dummy/config/initializers/wrap_parameters.rb +14 -0
  93. data/test/jruby_dummy/config/locales/en.yml +23 -0
  94. data/test/jruby_dummy/config/routes.rb +56 -0
  95. data/test/jruby_dummy/config/secrets.yml +22 -0
  96. data/test/jruby_dummy/db/schema.rb +15 -0
  97. data/test/jruby_dummy/public/404.html +67 -0
  98. data/test/jruby_dummy/public/422.html +67 -0
  99. data/test/jruby_dummy/public/500.html +66 -0
  100. data/test/jruby_dummy/public/favicon.ico +0 -0
  101. data/test/rails_packager/command_parser_test.rb +74 -0
  102. data/test/rails_packager/runner_test.rb +225 -0
  103. data/test/rails_packager/util_test.rb +84 -0
  104. data/test/rails_packager_test.rb +7 -0
  105. data/test/support/util_helper.rb +20 -0
  106. data/test/test_helper.rb +22 -0
  107. metadata +279 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,9 @@
1
+ env:
2
+ EXAMPLE: value
3
+ ENV_VAR: will be overridden
4
+ before:
5
+ - - command with_env
6
+ - env:
7
+ ENV_VAR: env value
8
+ OTHER: other value
9
+ - command without_env
@@ -0,0 +1,5 @@
1
+ before:
2
+ - - command with_env
3
+ - env:
4
+ ENV_VAR: env value
5
+ - command without_env
@@ -0,0 +1,7 @@
1
+ name: name-${NAME_ENV}
2
+ env:
3
+ EXAMPLE: env ${ENV_VALUE}
4
+ before:
5
+ - - ${COMMAND_VALUE} and ${ARGUMENT_VALUE} and missing-${MISSING_ARGUMENT_ENV_VARIABLE}-between
6
+ - env:
7
+ OTHER_EXAMPLE: env ${OTHER_ENV_VALUE}
@@ -0,0 +1,3 @@
1
+ before:
2
+ - pwd
3
+ package: echo Packaging
@@ -0,0 +1,6 @@
1
+ before:
2
+ - echo Before one
3
+ - 'false'
4
+ package: echo Packaging should not run
5
+ after:
6
+ - echo After should not run
@@ -0,0 +1,2 @@
1
+ before:
2
+ - echo "@{files} is within quotes"
@@ -0,0 +1,2 @@
1
+ before:
2
+ - echo @{files}.not.own.argument
@@ -0,0 +1,13 @@
1
+ exclude:
2
+ - log/**/*
3
+ name: packaged-0.0.1-SNAPSHOT
4
+ env:
5
+ EXAMPLE: first env var
6
+ EXAMPLE_2: second env var
7
+ before:
8
+ - echo this is before - @{name}
9
+ - echo this is also before
10
+ package: echo @{name}.tar.gz @{files}
11
+ after:
12
+ - echo this is after - @{name}
13
+ - echo this is also after @{files}
@@ -0,0 +1,5 @@
1
+ name: ''
2
+ before:
3
+ - '"" missing name'
4
+ - "@{name} missing name"
5
+ - "${EMPTY_COMMAND_NAME} missing name"
@@ -0,0 +1,2 @@
1
+ before:
2
+ - '"/bin/whenever however/whatever" some ''arguments "listed"'' with quotes'
@@ -0,0 +1,7 @@
1
+ before:
2
+ - echo Before one
3
+ - echo Before two
4
+ package: echo Packaging
5
+ after:
6
+ - echo After one
7
+ - echo After two
@@ -0,0 +1,224 @@
1
+ require "test_helper"
2
+
3
+ class IntegrationTest < ActiveSupport::TestCase
4
+ include RailsPackager::UtilHelper
5
+ teardown { close_runner }
6
+
7
+ test "execution path" do
8
+ runner = new_runner(config_file: config_file("execution-path.yml"), dir: DUMMY_RAILS_DIR)
9
+
10
+ out, err = capture_subprocess_io do
11
+ runner.execute
12
+ end
13
+
14
+ assert_equal strip_whitespace(<<-END), out
15
+ #{DUMMY_RAILS_DIR}
16
+ Packaging
17
+ END
18
+ assert_equal "", err
19
+ assert runner.successful?
20
+ end
21
+
22
+ test "simple integration" do
23
+ runner = new_runner(config_file: config_file("simple-integration.yml"), dir: DUMMY_RAILS_DIR)
24
+
25
+ out, err = capture_subprocess_io do
26
+ runner.execute
27
+ end
28
+
29
+ assert_equal strip_whitespace(<<-END), out
30
+ Before one
31
+ Before two
32
+ Packaging
33
+ After one
34
+ After two
35
+ END
36
+ assert_equal "", err
37
+ assert runner.successful?
38
+ end
39
+
40
+ test "simple integration with verbose" do
41
+ runner = new_runner(config_file: config_file("simple-integration.yml"), dir: DUMMY_RAILS_DIR)
42
+
43
+ out, err = capture_subprocess_io do
44
+ runner.execute(verbose: true)
45
+ end
46
+
47
+ assert_equal strip_whitespace(<<-END), out
48
+ $ echo Before one
49
+ Before one
50
+ $ echo Before two
51
+ Before two
52
+ $ echo Packaging
53
+ Packaging
54
+ $ echo After one
55
+ After one
56
+ $ echo After two
57
+ After two
58
+ END
59
+ assert_equal "", err
60
+ assert runner.successful?
61
+ end
62
+
63
+ test "integration from rails project" do
64
+ out, err = capture_subprocess_io do
65
+ system "cd '#{DUMMY_RAILS_DIR}' && rake package"
66
+ end
67
+
68
+ status = $?
69
+
70
+ assert_equal strip_whitespace(<<-END), out
71
+ Before one
72
+ Before two
73
+ Packaging dummy
74
+ After one
75
+ After two
76
+ END
77
+ assert_equal "", err
78
+ assert status.success?
79
+ end
80
+
81
+ test "debug with rake task" do
82
+ out, err = capture_subprocess_io do
83
+ system "cd '#{DUMMY_RAILS_DIR}' && rake package verbose=true"
84
+ end
85
+
86
+ status = $?
87
+
88
+ assert_equal strip_whitespace(<<-END), out
89
+ $ echo Before one
90
+ Before one
91
+ $ echo Before two
92
+ Before two
93
+ $ echo Packaging dummy
94
+ Packaging dummy
95
+ $ echo After one
96
+ After one
97
+ $ echo After two
98
+ After two
99
+ END
100
+ assert_equal "", err
101
+ assert status.success?
102
+ end
103
+
104
+ test "change name with rake task" do
105
+ out, err = capture_subprocess_io do
106
+ system "cd '#{DUMMY_RAILS_DIR}' && rake package[customized-1.0.0]"
107
+ end
108
+
109
+ status = $?
110
+
111
+ assert_equal strip_whitespace(<<-END), out
112
+ Before one
113
+ Before two
114
+ Packaging customized-1.0.0
115
+ After one
116
+ After two
117
+ END
118
+ assert_equal "", err
119
+ assert status.success?
120
+ end
121
+
122
+ test "integration from rails project with program form" do
123
+ out, err = capture_subprocess_io do
124
+ system "cd '#{DUMMY_RAILS_DIR}' && rails_package"
125
+ end
126
+
127
+ status = $?
128
+
129
+ assert_equal strip_whitespace(<<-END), out
130
+ Before one
131
+ Before two
132
+ Packaging dummy
133
+ After one
134
+ After two
135
+ END
136
+ assert_equal "", err
137
+ assert status.success?
138
+ end
139
+
140
+ test "program form with debug output" do
141
+ out, err = capture_subprocess_io do
142
+ system "cd '#{DUMMY_RAILS_DIR}' && rails_package -v"
143
+ end
144
+
145
+ status = $?
146
+
147
+ assert_equal strip_whitespace(<<-END), out
148
+ $ echo Before one
149
+ Before one
150
+ $ echo Before two
151
+ Before two
152
+ $ echo Packaging dummy
153
+ Packaging dummy
154
+ $ echo After one
155
+ After one
156
+ $ echo After two
157
+ After two
158
+ END
159
+ assert_equal "", err
160
+ assert status.success?
161
+ end
162
+
163
+ test "program form with customized name output" do
164
+ out, err = capture_subprocess_io do
165
+ system "cd '#{DUMMY_RAILS_DIR}' && rails_package --name customized-1.0.0"
166
+ end
167
+
168
+ status = $?
169
+
170
+ assert_equal strip_whitespace(<<-END), out
171
+ Before one
172
+ Before two
173
+ Packaging customized-1.0.0
174
+ After one
175
+ After two
176
+ END
177
+ assert_equal "", err
178
+ assert status.success?
179
+ end
180
+
181
+ test "failure integration" do
182
+ runner = new_runner(config_file: config_file("failure-integration.yml"), dir: DUMMY_RAILS_DIR)
183
+
184
+ out, err = capture_subprocess_io do
185
+ runner.execute
186
+ end
187
+
188
+ failed_command = runner.commands[1]
189
+
190
+ assert_equal strip_whitespace(<<-END), out
191
+ Before one
192
+ END
193
+ assert_equal strip_whitespace(<<-END), err
194
+ ERROR: 'false' returned error code: #{failed_command.exit_code}
195
+ END
196
+
197
+ assert_kind_of Integer, failed_command.exit_code
198
+ refute_equal 0, failed_command.exit_code
199
+ refute runner.successful?
200
+ end
201
+
202
+ test "failure integration with verbose" do
203
+ runner = new_runner(config_file: config_file("failure-integration.yml"), dir: DUMMY_RAILS_DIR)
204
+
205
+ out, err = capture_subprocess_io do
206
+ runner.execute(verbose: true)
207
+ end
208
+
209
+ failed_command = runner.commands[1]
210
+
211
+ assert_equal strip_whitespace(<<-END), out
212
+ $ echo Before one
213
+ Before one
214
+ $ false
215
+ END
216
+ assert_equal strip_whitespace(<<-END), err
217
+ ERROR: 'false' returned error code: #{failed_command.exit_code}
218
+ END
219
+
220
+ assert_kind_of Integer, failed_command.exit_code
221
+ refute_equal 0, failed_command.exit_code
222
+ refute runner.successful?
223
+ end
224
+ end