rugular 0.7.4 → 0.8.0
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
- data/.ruby-version +1 -1
- data/README.md +40 -3
- data/features/abstract.feature +20 -11
- data/features/build.feature +14 -0
- data/features/generator_for_directive.feature +1 -1
- data/lib/rugular/tasks/abstract.rb +65 -57
- data/lib/rugular/tasks/build.rb +11 -6
- data/lib/rugular/tasks/generate/generator_base.rb +10 -1
- data/lib/rugular/tasks/helpers/javascript_files.rb +10 -6
- data/lib/rugular/tasks/new.rb +8 -0
- data/lib/rugular/templates/new_erb/bower.json.erb +1 -0
- data/lib/rugular/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 139ae72be05b9e5148a8fc18e9b0dc4ce0d41b73
|
4
|
+
data.tar.gz: 8c62061df101cbf404bf784aa640b216779edf80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f6ede885b6538d37509ba5ef687c18754f2979453768cddc629c3f81517e81f142cc2c7b3ee773cee86f9d4f2df255d1303bd032e2e71c262244d1b9ec113e
|
7
|
+
data.tar.gz: 609fa6b7461e249a89bad153472e89cf47305f578e03aad846d87b8012c6ee81efc836f346fe6c8f0048dedc8c84bed7014d3e944975669e36e9f7a378c4aae0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.1
|
data/README.md
CHANGED
@@ -44,9 +44,11 @@ A new Rugular project contains the following folders and files:
|
|
44
44
|
├── .tmp/
|
45
45
|
├── bower_components/
|
46
46
|
├── bower.json
|
47
|
+
├── dist/
|
47
48
|
├── Gemfile
|
48
49
|
├── node_modules/
|
49
50
|
├── package.json
|
51
|
+
├── release/
|
50
52
|
├── src/
|
51
53
|
│ ├── app/
|
52
54
|
│ │ ├── _app.sass
|
@@ -70,9 +72,11 @@ A new Rugular project contains the following folders and files:
|
|
70
72
|
| .tmp | A temporary folder used for storing compiled Haml, Sass, and Coffeescript file, you do not need to edit any files in this folder. |
|
71
73
|
| bower_components | A folder used by bower to install packages. |
|
72
74
|
| bower.json | A list of packages to be installed by bower. |
|
75
|
+
| dist | A folder that contains production files created by the rugular build command |
|
73
76
|
| Gemfile | A way to install the ``rugular`` gem locally. This is not needed if you install ``rugular`` globally. |
|
74
77
|
| node_modules | A folder used by npm to install packages. |
|
75
78
|
| package.json | A list of packages to be installed by npm. |
|
79
|
+
| release | A folder that contains a manifest files to be used as a bower_component |
|
76
80
|
| src | A folder containing the source code unique to a rugular application. |
|
77
81
|
| src/app | A folder for application code that correlates to the layout of the application and a URL route in the application. A section is detailed below about [How to Write Rugular apps](#how-to-write-rugular-apps). |
|
78
82
|
| src/components | A folder for isolate-scope directives to be used in your application code. This folder is also described in [How to Write Rugular apps](#how-to-write-rugular-apps). |
|
@@ -89,7 +93,9 @@ bower_components or other 3rd party vendor files are declared in the
|
|
89
93
|
Code in the src folder are written in Coffeescript, Haml and Sass and designed
|
90
94
|
to follow [Google's Best Practices for an Angular App
|
91
95
|
Structure](https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub).
|
92
|
-
Rugular initially creates a ``src/app`` folder for logic pertaining to urls and
|
96
|
+
Rugular initially creates a ``src/app`` folder for logic pertaining to urls and
|
97
|
+
an ``src/components`` folder for abstracted web components, written as Angular
|
98
|
+
directives.
|
93
99
|
|
94
100
|
### The src/app folder
|
95
101
|
|
@@ -232,8 +238,8 @@ src/app/navbar.haml
|
|
232
238
|
src/app/navbar.module.coffee
|
233
239
|
```
|
234
240
|
|
235
|
-
> This will be re-written as a component in Angular 2.0.
|
236
|
-
>
|
241
|
+
> This will be re-written as a component in Angular 2.0. (and it will be
|
242
|
+
> awesome!)
|
237
243
|
|
238
244
|
#### Create a Factory
|
239
245
|
|
@@ -297,6 +303,37 @@ start a new tmuxinator session, type:
|
|
297
303
|
bundle exec rugular tmux
|
298
304
|
```
|
299
305
|
|
306
|
+
## Abstracting Bower Components
|
307
|
+
|
308
|
+
Rugular allows users to abstract both the ``components`` and ``app`` folder as
|
309
|
+
one bower_component, or just the ``components`` folder as a bower_component. A
|
310
|
+
new manifest file will be created in the ``release`` folder of your application
|
311
|
+
and the version in the ``bower.json`` file will be updated.
|
312
|
+
|
313
|
+
### App and Components Bower Component
|
314
|
+
|
315
|
+
To create a bower component with both the ``app`` and ``components`` folder
|
316
|
+
run:
|
317
|
+
|
318
|
+
```bash
|
319
|
+
bundle exec rugular abstract
|
320
|
+
```
|
321
|
+
|
322
|
+
This will create the manifest ``release/#{your_app_name}.js`` file. Running
|
323
|
+
this command multiple times will override the file.
|
324
|
+
|
325
|
+
### Components Bower Component
|
326
|
+
|
327
|
+
To create a bower component with both the ``app`` and ``components`` folder
|
328
|
+
run:
|
329
|
+
|
330
|
+
```bash
|
331
|
+
bundle exec rugular abstract -c
|
332
|
+
```
|
333
|
+
|
334
|
+
This will also create the manifest ``release/#{your_app_name}.js`` file.
|
335
|
+
Running this command multiple times will override the file.
|
336
|
+
|
300
337
|
## Running the tests
|
301
338
|
|
302
339
|
### During development
|
data/features/abstract.feature
CHANGED
@@ -2,22 +2,31 @@
|
|
2
2
|
Feature: Rugular CLI
|
3
3
|
In order to abstract bower components
|
4
4
|
As a user of the rugular framework
|
5
|
-
I want to create a bower_component from
|
5
|
+
I want to create a bower_component from my rugular application
|
6
6
|
|
7
7
|
# Scenario: Abstracting components folder
|
8
|
-
# When I set up Rugular and run "rugular g directive test"
|
9
|
-
#
|
10
|
-
# Then the file "~/bower_components/myapp/bower.json" should contain:
|
8
|
+
# When I set up Rugular and run "rugular g directive test && rugular abstract -c"
|
9
|
+
# Then the file "my-app/bower.json" should contain:
|
11
10
|
# """
|
12
|
-
# "
|
11
|
+
# "version": "0.0.0",
|
13
12
|
# """
|
14
|
-
#
|
13
|
+
# And a file named "my-app/release/my-app.js" should exist
|
14
|
+
# And a file named "my-app/release/my-app.css" should exist
|
15
|
+
|
15
16
|
# Scenario: Abstracting both the app and components folder
|
16
|
-
# When I set up Rugular and run "rugular g directive test"
|
17
|
-
#
|
18
|
-
# Then the file "~/bower_components/myapp/bower.json" should contain:
|
17
|
+
# When I set up Rugular and run "rugular g directive test && rugular abstract"
|
18
|
+
# Then the file "my-app/bower.json" should contain:
|
19
19
|
# """
|
20
|
-
# "
|
20
|
+
# "version": "0.0.0",
|
21
21
|
# """
|
22
|
+
# And a file named "my-app/release/my-app.js" should exist
|
23
|
+
# And a file named "my-app/release/my-app.css" should exist
|
22
24
|
#
|
23
|
-
|
25
|
+
Scenario: Abstracting both the app and components folder twice
|
26
|
+
When I set up Rugular and run "rugular g directive test && rugular abstract && rugular abstract"
|
27
|
+
Then the file "my-app/bower.json" should contain:
|
28
|
+
"""
|
29
|
+
"0.0.1"
|
30
|
+
"""
|
31
|
+
And a file named "my-app/release/my-app.js" should exist
|
32
|
+
And a file named "my-app/release/my-app.css" should exist
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@increase_wait_time
|
2
|
+
Feature: Rugular CLI
|
3
|
+
In order to create production files
|
4
|
+
As a user of the rugular framework
|
5
|
+
I want to create manifest js and css files
|
6
|
+
|
7
|
+
Scenario: Building the dist folder
|
8
|
+
When I set up Rugular and run "cd tmp/aruba/my-app && rugular build`
|
9
|
+
Then a file named "tmp/aruba/myapp/dist/index.html" should exist
|
10
|
+
Then a file named "tmp/aruba/myapp/dist/application.css" should exist
|
11
|
+
Then a file named "tmp/aruba/myapp/dist/application.js" should exist
|
12
|
+
Then a file named "tmp/aruba/myapp/dist/vendor.css" should exist
|
13
|
+
Then a file named "tmp/aruba/myapp/dist/vendor.js" should exist
|
14
|
+
|
@@ -4,7 +4,7 @@ Feature: Rugular CLI
|
|
4
4
|
I want to bootstrap the templates necessary to carry this out
|
5
5
|
|
6
6
|
Scenario: Generating a route
|
7
|
-
When I set up Rugular and run "rugular generate directive test"
|
7
|
+
When I set up Rugular and run "rugular generate directive -c test"
|
8
8
|
Then the file "my-app/src/components/test/test.directive.coffee" should contain:
|
9
9
|
"""
|
10
10
|
angular.module('test').directive('test', test)
|
@@ -1,17 +1,22 @@
|
|
1
|
+
Dir.glob("#{__dir__}/helpers/**/*.rb").each { |file| require file }
|
2
|
+
require 'uglifier'
|
3
|
+
require 'coffee_script'
|
4
|
+
require 'sass'
|
5
|
+
require 'haml'
|
6
|
+
|
1
7
|
module Rugular
|
2
8
|
class Abstract < Thor::Group
|
3
9
|
include Thor::Actions
|
4
10
|
|
5
|
-
|
11
|
+
class_option(
|
12
|
+
:c,
|
13
|
+
type: :boolean,
|
14
|
+
desc: 'Create a component with just the component folder'
|
15
|
+
)
|
16
|
+
|
6
17
|
desc <<-DESC
|
7
|
-
|
8
|
-
|
9
|
-
it is treated like a bower component.
|
10
|
-
|
11
|
-
The command will ask some setup questions to generate a bower.json. It is
|
12
|
-
recommended that the bower component folders generated by rugular are NOT
|
13
|
-
edited by hand. Instead, the only updates should occur by repeated use of
|
14
|
-
the ``rugular abstract`` command.
|
18
|
+
Creates a release manifest javascript file to be used as a bower
|
19
|
+
component
|
15
20
|
DESC
|
16
21
|
|
17
22
|
def check_for_rugular_directory
|
@@ -21,79 +26,82 @@ module Rugular
|
|
21
26
|
)
|
22
27
|
end
|
23
28
|
|
24
|
-
def
|
25
|
-
|
29
|
+
def bower_json
|
30
|
+
@_json ||= JSON.parse(File.read('bower.json')).to_h
|
26
31
|
end
|
27
32
|
|
28
|
-
def
|
29
|
-
|
30
|
-
end
|
33
|
+
def increment_bower_version_if_file_exists
|
34
|
+
return unless File.exists? "release/#{app_name}.js"
|
31
35
|
|
32
|
-
|
33
|
-
|
36
|
+
new_bower_json = bower_json.tap do |json|
|
37
|
+
json['version'] = next_version
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
bower_open_struct.instance_eval { binding }
|
38
|
-
)
|
40
|
+
File.open('bower.json', 'w') do |file|
|
41
|
+
file.write new_bower_json
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
|
-
|
45
|
+
def write_release_js_file
|
46
|
+
File.open(release_js, 'w') do |file|
|
47
|
+
file.write(
|
48
|
+
Uglifier.compile(
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
javascript_files.map do |javascript_file|
|
51
|
+
CoffeeScript.compile(
|
52
|
+
File.read(javascript_file).gsub('templateUrl', 'template')
|
53
|
+
)
|
54
|
+
end.join
|
47
55
|
|
48
|
-
|
49
|
-
|
56
|
+
)
|
57
|
+
)
|
58
|
+
end
|
50
59
|
end
|
51
60
|
|
52
|
-
def
|
53
|
-
|
61
|
+
def inline_template_url_files
|
62
|
+
(Dir.glob('**/*.haml') - ['src/index.haml']).each do |haml_file|
|
63
|
+
haml_html = ::Haml::Engine.new(File.read(haml_file), {}).render
|
54
64
|
|
55
|
-
|
56
|
-
end
|
65
|
+
html = haml_html.tr("\n", '').gsub("'", "\'").gsub('"', '\"')
|
57
66
|
|
58
|
-
|
59
|
-
JSON.parse(File.read('bower.json'))
|
60
|
-
end
|
67
|
+
html_filename = haml_file.gsub('src/', '').gsub('haml', 'html')
|
61
68
|
|
62
|
-
|
63
|
-
|
69
|
+
IO.write(release_js, File.open(release_js) do |f|
|
70
|
+
f.read.gsub(html_filename, html)
|
71
|
+
end)
|
72
|
+
end
|
64
73
|
end
|
65
74
|
|
66
|
-
def
|
67
|
-
|
75
|
+
def write_application_css_file
|
76
|
+
`sass .application.sass release/#{app_name}.css -r sass-globbing`
|
68
77
|
end
|
69
78
|
|
70
|
-
|
71
|
-
|
79
|
+
private
|
80
|
+
|
81
|
+
def app_name
|
82
|
+
destination_root.split('/').last
|
72
83
|
end
|
73
84
|
|
74
|
-
def
|
75
|
-
|
76
|
-
File.basename(filename)
|
77
|
-
end
|
85
|
+
def previous_version
|
86
|
+
bower_json.fetch('version')
|
78
87
|
end
|
79
88
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
git_username: git_username,
|
85
|
-
description: folder,
|
86
|
-
main_javascript_files: main_javascript_files,
|
87
|
-
dev_dependencies: bower_json.fetch('devDependencies', {}),
|
88
|
-
dependencies: bower_json.fetch('dependencies', {}),
|
89
|
-
resolutions: bower_json.fetch('resolutions', {})
|
90
|
-
)
|
89
|
+
def next_version
|
90
|
+
next_patch = previous_version.split('.').last.to_i + 1
|
91
|
+
|
92
|
+
(previous_version.split('.')[0..-2] << next_patch).join('.')
|
91
93
|
end
|
92
94
|
|
93
|
-
def
|
94
|
-
|
95
|
+
def javascript_files
|
96
|
+
if options[:c]
|
97
|
+
::Rugular::JavascriptFiles.component_array
|
98
|
+
else
|
99
|
+
::Rugular::JavascriptFiles.ordered_array
|
100
|
+
end
|
101
|
+
end
|
95
102
|
|
96
|
-
|
103
|
+
def release_js
|
104
|
+
"release/#{app_name}.js"
|
97
105
|
end
|
98
106
|
end
|
99
107
|
end
|
data/lib/rugular/tasks/build.rb
CHANGED
@@ -11,11 +11,10 @@ module Rugular
|
|
11
11
|
desc('Creates a minified, compressed version in the dist folder')
|
12
12
|
|
13
13
|
def check_for_rugular_directory
|
14
|
-
Rugular::AppChecker.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
FileUtils.mkdir_p('./dist') unless File.directory? './dist'
|
14
|
+
Rugular::AppChecker.check_for_rugular_directory(
|
15
|
+
task_name: name,
|
16
|
+
root_directory: new.destination_root
|
17
|
+
)
|
19
18
|
end
|
20
19
|
|
21
20
|
def write_dist_index_html_file
|
@@ -40,10 +39,13 @@ module Rugular
|
|
40
39
|
File.open('dist/application.js', 'w') do |file|
|
41
40
|
file.write(
|
42
41
|
Uglifier.compile(
|
43
|
-
|
42
|
+
|
43
|
+
Rugular::JavascriptFiles.ordered_array.map do |javascript_file|
|
44
44
|
text = File.read(javascript_file).gsub('templateUrl', 'template')
|
45
|
+
|
45
46
|
CoffeeScript.compile(text)
|
46
47
|
end.join
|
48
|
+
|
47
49
|
)
|
48
50
|
)
|
49
51
|
end
|
@@ -52,8 +54,11 @@ module Rugular
|
|
52
54
|
def inline_template_url_files
|
53
55
|
(Dir.glob("**/*.haml") - ["src/index.haml"]).each do |haml_file|
|
54
56
|
haml_html = ::Haml::Engine.new(File.read(haml_file), {}).render
|
57
|
+
|
55
58
|
html = haml_html.tr("\n", '').gsub("'", "\'").gsub('"', '\"')
|
59
|
+
|
56
60
|
html_filename = haml_file.gsub('src/', '').gsub('haml', 'html')
|
61
|
+
|
57
62
|
IO.write('dist/application.js', File.open('dist/application.js') do |f|
|
58
63
|
f.read.gsub(html_filename, html)
|
59
64
|
end)
|
@@ -7,6 +7,12 @@ module Rugular
|
|
7
7
|
|
8
8
|
argument :name, desc: 'Name for your route'
|
9
9
|
|
10
|
+
class_option(
|
11
|
+
:c,
|
12
|
+
type: :boolean,
|
13
|
+
desc: 'create the route in the component folder'
|
14
|
+
)
|
15
|
+
|
10
16
|
def self.source_root
|
11
17
|
__dir__.chomp('/tasks/generate')
|
12
18
|
end
|
@@ -42,7 +48,6 @@ module Rugular
|
|
42
48
|
end
|
43
49
|
|
44
50
|
def template_files; []; end
|
45
|
-
def app_or_component; 'components' end
|
46
51
|
|
47
52
|
protected
|
48
53
|
|
@@ -100,5 +105,9 @@ module Rugular
|
|
100
105
|
"src/#{app_or_component}/#{name.split(':')[0..-2].join('/')}/"\
|
101
106
|
"#{nested_module_name}.module.coffee"
|
102
107
|
end
|
108
|
+
|
109
|
+
def app_or_component
|
110
|
+
options[:c] ? 'components' : 'app'
|
111
|
+
end
|
103
112
|
end
|
104
113
|
end
|
@@ -1,12 +1,7 @@
|
|
1
1
|
module Rugular
|
2
2
|
class JavascriptFiles
|
3
3
|
def self.ordered_array
|
4
|
-
|
5
|
-
Dir.glob('src/components/**/*.constant.coffee') +
|
6
|
-
Dir.glob('src/components/**/*.factory.coffee') +
|
7
|
-
Dir.glob('src/components/**/*.filter.coffee') +
|
8
|
-
Dir.glob('src/components/**/*.controller.coffee') +
|
9
|
-
Dir.glob('src/components/**/*.directive.coffee') +
|
4
|
+
component_array +
|
10
5
|
Dir.glob('src/app/**/*.module.coffee') +
|
11
6
|
Dir.glob('src/app/**/*.config.coffee') +
|
12
7
|
Dir.glob('src/app/**/*.constant.coffee') +
|
@@ -14,5 +9,14 @@ module Rugular
|
|
14
9
|
Dir.glob('src/app/**/*.controller.coffee') +
|
15
10
|
Dir.glob('src/app/**/*.routes.coffee')
|
16
11
|
end
|
12
|
+
|
13
|
+
def self.component_array
|
14
|
+
Dir.glob('src/components/**/*.module.coffee') +
|
15
|
+
Dir.glob('src/components/**/*.constant.coffee') +
|
16
|
+
Dir.glob('src/components/**/*.factory.coffee') +
|
17
|
+
Dir.glob('src/components/**/*.filter.coffee') +
|
18
|
+
Dir.glob('src/components/**/*.controller.coffee') +
|
19
|
+
Dir.glob('src/components/**/*.directive.coffee')
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/rugular/tasks/new.rb
CHANGED
@@ -36,6 +36,14 @@ module Rugular
|
|
36
36
|
empty_directory "#{app_name}/vendor"
|
37
37
|
end
|
38
38
|
|
39
|
+
def create_dist_directory
|
40
|
+
empty_directory "#{app_name}/dist"
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_release_directory
|
44
|
+
empty_directory "#{app_name}/release"
|
45
|
+
end
|
46
|
+
|
39
47
|
def install_bourbon
|
40
48
|
run "cd #{app_name}/vendor && bourbon install "\
|
41
49
|
'&& neat install && bitters install'
|
data/lib/rugular/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rugular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Shook
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -309,6 +309,7 @@ files:
|
|
309
309
|
- bower.json
|
310
310
|
- circle.yml
|
311
311
|
- features/abstract.feature
|
312
|
+
- features/build.feature
|
312
313
|
- features/continuous_integration.feature
|
313
314
|
- features/generator_for_directive.feature
|
314
315
|
- features/generator_for_route.feature
|
@@ -410,6 +411,7 @@ specification_version: 4
|
|
410
411
|
summary: Rugular - a ruby scaffolding framework for AngularJS
|
411
412
|
test_files:
|
412
413
|
- features/abstract.feature
|
414
|
+
- features/build.feature
|
413
415
|
- features/continuous_integration.feature
|
414
416
|
- features/generator_for_directive.feature
|
415
417
|
- features/generator_for_route.feature
|