rang 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 +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +195 -0
- data/Rakefile +1 -0
- data/TODO.md +43 -0
- data/app/controllers/rang/application_controller.rb +4 -0
- data/app/controllers/rang/root_controller.rb +7 -0
- data/config/routes.rb +3 -0
- data/lib/rails/generators/rang/add_root/add_root_generator.rb +12 -0
- data/lib/rails/generators/rang/api/configure/configure_generator.rb +70 -0
- data/lib/rails/generators/rang/api/configure/templates/active_model_serializer.rb +5 -0
- data/lib/rails/generators/rang/assets/init/init_generator.rb +52 -0
- data/lib/rails/generators/rang/assets/init/templates/_base.scss +11 -0
- data/lib/rails/generators/rang/assets/init/templates/application.js +14 -0
- data/lib/rails/generators/rang/assets/init/templates/application.scss +3 -0
- data/lib/rails/generators/rang/assets/init/templates/components.js +2 -0
- data/lib/rails/generators/rang/bower/add/add_generator.rb +48 -0
- data/lib/rails/generators/rang/bower/bower_generator.rb +28 -0
- data/lib/rails/generators/rang/bower/init/init_generator.rb +35 -0
- data/lib/rails/generators/rang/example/example_generator.rb +17 -0
- data/lib/rails/generators/rang/example/templates/frontend/application.js.tt +21 -0
- data/lib/rails/generators/rang/example/templates/frontend/application.scss +6 -0
- data/lib/rails/generators/rang/example/templates/frontend/components/components.js +2 -0
- data/lib/rails/generators/rang/example/templates/frontend/components/simple_format/simple_format.directive.js +12 -0
- data/lib/rails/generators/rang/example/templates/frontend/components/simple_format/simple_format.module.js +4 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/index.ctrl.js.tt +6 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/index.ctrl.spec.js.tt +12 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/index.slim.tt +14 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/posts.module.js.tt +12 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/posts.scss +3 -0
- data/lib/rails/generators/rang/example/templates/frontend/posts/posts.service.js.tt +44 -0
- data/lib/rails/generators/rang/example/templates/frontend/style/_base.scss +11 -0
- data/lib/rails/generators/rang/example/templates/frontend/style/_layout.scss +3 -0
- data/lib/rails/generators/rang/install/install_generator.rb +66 -0
- data/lib/rails/generators/rang/install/templates/rang.rb +25 -0
- data/lib/rails/generators/rang/teaspoon/install/install_generator.rb +75 -0
- data/lib/rang.rb +18 -0
- data/lib/rang/config.rb +12 -0
- data/lib/rang/engine/railtie.rb +5 -0
- data/lib/rang/helpers.rb +35 -0
- data/lib/rang/patcher.rb +50 -0
- data/lib/rang/util.rb +11 -0
- data/lib/rang/version.rb +3 -0
- data/rang.gemspec +29 -0
- data/spec/controllers/root_controller_spec.rb +12 -0
- data/spec/generators/add_root_spec.rb +21 -0
- data/spec/generators/api_configure_spec.rb +44 -0
- data/spec/generators/assets_init_spec.rb +91 -0
- data/spec/generators/bower_add_spec.rb +61 -0
- data/spec/generators/bower_init_spec.rb +57 -0
- data/spec/generators/install_spec.rb +40 -0
- data/spec/generators/teaspoon_install_spec.rb +123 -0
- data/spec/helpers_spec.rb +64 -0
- data/spec/patcher_spec.rb +103 -0
- data/spec/rails_app/.gitignore +16 -0
- data/spec/rails_app/Gemfile +41 -0
- data/spec/rails_app/README.rdoc +28 -0
- data/spec/rails_app/Rakefile +6 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/assets/javascripts/application.js +16 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_app/app/controllers/application_controller.rb +5 -0
- data/spec/rails_app/app/controllers/concerns/.keep +0 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/mailers/.keep +0 -0
- data/spec/rails_app/app/models/.keep +0 -0
- data/spec/rails_app/app/models/concerns/.keep +0 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
- data/spec/rails_app/bin/bundle +3 -0
- data/spec/rails_app/bin/rails +8 -0
- data/spec/rails_app/bin/rake +8 -0
- data/spec/rails_app/bin/spring +18 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +23 -0
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/database.yml +25 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +37 -0
- data/spec/rails_app/config/environments/production.rb +82 -0
- data/spec/rails_app/config/environments/test.rb +39 -0
- data/spec/rails_app/config/initializers/assets.rb +8 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails_app/config/initializers/inflections.rb +16 -0
- data/spec/rails_app/config/initializers/mime_types.rb +4 -0
- data/spec/rails_app/config/initializers/session_store.rb +3 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/en.yml +23 -0
- data/spec/rails_app/config/routes.rb +56 -0
- data/spec/rails_app/config/secrets.yml +22 -0
- data/spec/rails_app/db/seeds.rb +7 -0
- data/spec/rails_app/lib/assets/.keep +0 -0
- data/spec/rails_app/lib/tasks/.keep +0 -0
- data/spec/rails_app/log/.keep +0 -0
- data/spec/rails_app/public/404.html +67 -0
- data/spec/rails_app/public/422.html +67 -0
- data/spec/rails_app/public/500.html +66 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/test/controllers/.keep +0 -0
- data/spec/rails_app/test/fixtures/.keep +0 -0
- data/spec/rails_app/test/helpers/.keep +0 -0
- data/spec/rails_app/test/integration/.keep +0 -0
- data/spec/rails_app/test/mailers/.keep +0 -0
- data/spec/rails_app/test/models/.keep +0 -0
- data/spec/rails_app/test/test_helper.rb +10 -0
- data/spec/rails_app/vendor/assets/javascripts/.keep +0 -0
- data/spec/rails_app/vendor/assets/stylesheets/.keep +0 -0
- data/spec/spec_helper.rb +79 -0
- data/spec/util_spec.rb +27 -0
- data/spec/version_spec.rb +9 -0
- data/vendor/assets/javascripts/angular-templates.js.erb +14 -0
- metadata +327 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//= require angular
|
|
2
|
+
//= require angular-route
|
|
3
|
+
//= require angular-templates
|
|
4
|
+
|
|
5
|
+
// You should require module manifests from this file, e.g. require posts/posts
|
|
6
|
+
// Those manifests should specify their own dependencies.
|
|
7
|
+
|
|
8
|
+
angular.module('<%= Rang::Util.application_name %>', ['ngRoute'])
|
|
9
|
+
.config(function($routeProvider) {
|
|
10
|
+
$routeProvider.otherwise({
|
|
11
|
+
redirectTo: '/'
|
|
12
|
+
});
|
|
13
|
+
})
|
|
14
|
+
.run(AngularTemplates.load);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Bower
|
|
3
|
+
module Generators
|
|
4
|
+
class AddGenerator < Rails::Generators::Base
|
|
5
|
+
argument :dependency_name, type: :string
|
|
6
|
+
argument :version_string, type: :string, default: ''
|
|
7
|
+
desc "Adds a dependency to Gemfile.bower."
|
|
8
|
+
|
|
9
|
+
def run_init
|
|
10
|
+
generate "rang:bower:init" unless File.exist? 'Gemfile.bower'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def add_gem_to_bower_gemfile
|
|
14
|
+
append_file "Gemfile.bower", "gem '#{gem_package}'" +
|
|
15
|
+
(", '#{version_string}'" unless version_string.empty?).to_s +
|
|
16
|
+
"\n"
|
|
17
|
+
bundle! if run_bundler?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def notify_add
|
|
21
|
+
unless args.include? 'quiet'
|
|
22
|
+
say("Don't forget to add #{bower_package} to application.js!", :cyan)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def gem_package
|
|
29
|
+
"rails-assets-#{bower_package}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def bower_package
|
|
33
|
+
dependency_name.delete('@')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def bundle!
|
|
37
|
+
Bundler.with_clean_env do
|
|
38
|
+
run "bundle install"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def run_bundler?
|
|
43
|
+
dependency_name.ends_with? '@'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Bower
|
|
3
|
+
module Generators
|
|
4
|
+
class InitGenerator < Rails::Generators::Base
|
|
5
|
+
desc "Creates an auxilliary Gemfile for bower assets."
|
|
6
|
+
|
|
7
|
+
def create_bower_gemfile
|
|
8
|
+
create_file "Gemfile.bower", "source 'https://rails-assets.org'\n"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def include_bower_gemfile_into_gemfile
|
|
12
|
+
append_file "Gemfile", "\n"+
|
|
13
|
+
"# Include bower.json for assets via https://rails-assets.org/.\n"+
|
|
14
|
+
"eval(IO.read('Gemfile.bower'), binding)\n"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class AddGenerator < Rails::Generators::NamedBase
|
|
19
|
+
argument :dependency_name, type: :string
|
|
20
|
+
desc "Adds a dependency to Gemfile.bower."
|
|
21
|
+
|
|
22
|
+
def add_gem_to_bower_gemfile
|
|
23
|
+
append_file
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Bower
|
|
3
|
+
module Generators
|
|
4
|
+
class InitGenerator < Rails::Generators::Base
|
|
5
|
+
desc "Creates an auxilliary Gemfile for bower assets."
|
|
6
|
+
|
|
7
|
+
def create_bower_gemfile
|
|
8
|
+
create_file "Gemfile.bower", "" +
|
|
9
|
+
"source 'https://rails-assets.org'\n"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def include_bower_gemfile_into_gemfile
|
|
13
|
+
inject_into_file "Gemfile", after: /source.*$/ do
|
|
14
|
+
"\n\n# Include Gemfile.bower for assets via https://rails-assets.org/.\n" +
|
|
15
|
+
"eval(IO.read('Gemfile.bower'), binding) if File.exist? 'Gemfile.bower'"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def add_angular_gems
|
|
20
|
+
generate "rang:bower:add", "angular '~> 1.2.0' quiet"
|
|
21
|
+
generate "rang:bower:add", "angular-route '~> 1.2.0' quiet"
|
|
22
|
+
bundle!
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def bundle!
|
|
28
|
+
Bundler.with_clean_env do
|
|
29
|
+
run "bundle install"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Generators
|
|
3
|
+
class ExampleGenerator < Rails::Generators::Base
|
|
4
|
+
desc "Copies example assets to frontend."
|
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
6
|
+
|
|
7
|
+
def clobber_assets
|
|
8
|
+
remove_dir 'app/assets/frontend'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy_example
|
|
12
|
+
directory 'frontend', 'app/assets/frontend/'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//= require angular
|
|
2
|
+
//= require angular-restmod/angular-restmod-bundle
|
|
3
|
+
//= require angular-route
|
|
4
|
+
//= require angular-templates
|
|
5
|
+
|
|
6
|
+
//= require components/simple_format/simple_format.module
|
|
7
|
+
//= require posts/posts.module
|
|
8
|
+
|
|
9
|
+
// You should require module manifests from this file, e.g. require posts/posts
|
|
10
|
+
// Those manifests should specify their own dependencies.
|
|
11
|
+
|
|
12
|
+
angular.module('<%= Rang::Util.application_name %>', [
|
|
13
|
+
'ngRoute',
|
|
14
|
+
'<%= Rang::Util.application_name %>.posts',
|
|
15
|
+
'shared.simpleFormat'
|
|
16
|
+
]).config(function($routeProvider) {
|
|
17
|
+
$routeProvider.otherwise({
|
|
18
|
+
redirectTo: '/posts'
|
|
19
|
+
});
|
|
20
|
+
})
|
|
21
|
+
.run(AngularTemplates.load);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
angular.module('shared.simpleFormat').directive('simpleFormat', function(){
|
|
2
|
+
return {
|
|
3
|
+
replace: true,
|
|
4
|
+
scope: {
|
|
5
|
+
simpleFormat: '='
|
|
6
|
+
},
|
|
7
|
+
controller: function($scope) {
|
|
8
|
+
$scope.paragraphs = $scope.simpleFormat.split("\n\n")
|
|
9
|
+
},
|
|
10
|
+
template: '<p ng-repeat="paragraph in paragraphs">{{paragraph}}</p>'
|
|
11
|
+
}
|
|
12
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
describe('PostsIndexCtrl', function(){
|
|
2
|
+
|
|
3
|
+
beforeEach(module('<%= Rang::Util.application_name %>.posts'));
|
|
4
|
+
|
|
5
|
+
it('it should provide posts on scope', inject(function($controller) {
|
|
6
|
+
var scope = {},
|
|
7
|
+
ctrl = $controller('PostsIndexCtrl', {$scope:scope});
|
|
8
|
+
|
|
9
|
+
expect(scope.posts.length).toBe(2);
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.container
|
|
2
|
+
.row
|
|
3
|
+
.col-md-8.col-md-offset-2
|
|
4
|
+
.jumbotron
|
|
5
|
+
h1 <%= Rang::Util.application_name %> Blog
|
|
6
|
+
p This is a fake blog to demonstrate <a href="http://github.com/cultivatehq/rang">Rang</a>
|
|
7
|
+
|
|
8
|
+
.post ng-repeat="post in posts"
|
|
9
|
+
h2 {{post.title}}
|
|
10
|
+
.media
|
|
11
|
+
.pull-left ng-if="post.image"
|
|
12
|
+
img.media-object ng-src="{{post.image}}"
|
|
13
|
+
.media-body
|
|
14
|
+
div simple-format="post.body"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//= require_self
|
|
2
|
+
//= require ./posts.service
|
|
3
|
+
//= require ./index.ctrl
|
|
4
|
+
|
|
5
|
+
angular.module('<%= Rang::Util.application_name %>.posts', ['ngRoute'])
|
|
6
|
+
.config(function($routeProvider) {
|
|
7
|
+
$routeProvider
|
|
8
|
+
.when('/posts', {
|
|
9
|
+
controller: 'PostsIndexCtrl',
|
|
10
|
+
templateUrl: '/assets/posts/index.html'
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The text in this file is taken from Wikipedia and licensed under the CC BY-SA
|
|
2
|
+
// http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License
|
|
3
|
+
|
|
4
|
+
angular.module('<%= Rang::Util.application_name %>.posts').service('PostsService', function() {
|
|
5
|
+
|
|
6
|
+
var posts = [
|
|
7
|
+
{
|
|
8
|
+
title: 'Oleg Popov',
|
|
9
|
+
body: 'Oleg Konstantinovich Popov (Russian: Олег Константинович Попо́в, ' +
|
|
10
|
+
'born 31 July 1930) is a famous Soviet and Russian clown and circus ' +
|
|
11
|
+
'artist. Popov is also called the "Sunshine clown".\n\n' +
|
|
12
|
+
'He was born on 31 July 1930 in Moscow, the son of a clock-maker. ' +
|
|
13
|
+
'He studied elements of acrobatics, juggling, and other circus ' +
|
|
14
|
+
'skills in his youth. In 1949, he graduated from the Russian circus ' +
|
|
15
|
+
'school in Moscow and started his career in the Moscow Circus on ' +
|
|
16
|
+
'Tsvetnoy Boulevard. Six years later, he became the first clown from ' +
|
|
17
|
+
'the Union of Soviet Socialist Republics to perform in the Western ' +
|
|
18
|
+
'world. In 1969, he was honored with the title of People\'s Artist ' +
|
|
19
|
+
'of the USSR. Popov\'s fame extended to Melbourne, Australia, where ' +
|
|
20
|
+
'he was named King of Moomba (1971).'
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
title: 'Grock',
|
|
25
|
+
image: 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Grock_1903.jpg/108px-Grock_1903.jpg',
|
|
26
|
+
body: 'Grock (January 10, 1880 – July 14, 1959), born Charles Adrien ' +
|
|
27
|
+
'Wettach, was a Swiss clown, composer and musician. Called "the ' +
|
|
28
|
+
'king of clowns" and "the greatest of Europe\'s clowns", Grock was ' +
|
|
29
|
+
'once the most highly paid entertainer in the world.\n\n' +
|
|
30
|
+
'Grock was born in Loveresse, a village in the Bernese Jura in the C' +
|
|
31
|
+
'anton of Bern. He started early as a performer, learning musiciansh' +
|
|
32
|
+
'ip and acrobatic skills from his father. When a caravan of Roma ' +
|
|
33
|
+
'passed through, he joined them, learning more instruments and gaini' +
|
|
34
|
+
'ng confidence with them. In 1894, he debuted with Fiame Wetzel\'s t' +
|
|
35
|
+
'raveling circus. He become a clown, working first with Brick in ' +
|
|
36
|
+
'1903, adopting the name "Grock", and then the famous clown Antonet ' +
|
|
37
|
+
'(Umberto Guillaum).'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
posts: posts
|
|
43
|
+
}
|
|
44
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
desc "Installs Rang."
|
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
6
|
+
|
|
7
|
+
def init
|
|
8
|
+
@can_add_examples = true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def install_initializer
|
|
12
|
+
template "rang.rb", "config/initializers/rang.rb"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def install_bower
|
|
16
|
+
if !no? "\n\nSet up Gemfile.bower for frontend assets? [Yn]", :cyan
|
|
17
|
+
generate "rang:bower:init"
|
|
18
|
+
else
|
|
19
|
+
@can_add_examples = false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def restructure_assets
|
|
24
|
+
if !no? "\n\nRestructure assets/ to follow Angular recommended structure? [Yn]", :cyan
|
|
25
|
+
generate "rang:assets:init"
|
|
26
|
+
else
|
|
27
|
+
@can_add_examples = false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def configure_api
|
|
32
|
+
if !no? "\n\nConfigure default API interface with active_model_serializers and angular-restmod? [Yn]", :cyan
|
|
33
|
+
generate "rang:api:configure"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def install_teaspoon
|
|
38
|
+
if !no? "\n\nInstall & configure Teaspoon for Angular/Jasmine tests? [Yn]", :cyan
|
|
39
|
+
generate "rang:teaspoon:install"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def add_root_route
|
|
44
|
+
if !no? "\n\nAdd default root route pointing to an ng-view tag? [Yn]", :cyan
|
|
45
|
+
generate "rang:add_root"
|
|
46
|
+
else
|
|
47
|
+
@can_add_examples = false
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def add_example_assets
|
|
52
|
+
if @can_add_examples && yes?("\n\nAdd example assets to demonstrate usage? [yN]", :cyan)
|
|
53
|
+
generate "rang:example"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def usage
|
|
58
|
+
say "\n\n ****** \n\n"
|
|
59
|
+
say "Rang is now set-up.\n\n", :green
|
|
60
|
+
say "Use `rails g rang:bower:add package '~> 0.1'` to install bower packages.", :cyan
|
|
61
|
+
say "See README for full docs: https://github.com/CultivateHQ/rang/blob/master/README.md\n\n"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Rang.configure do |config|
|
|
2
|
+
|
|
3
|
+
# This does some admittedly ugly patching to allow you to address your
|
|
4
|
+
# templates with the more intuitive extension '.html' rather than '.htm'.
|
|
5
|
+
#
|
|
6
|
+
# If you prefer, you can disable this and ensure your asset filenames follow
|
|
7
|
+
# the format `file.html.slim` — you'll still need to refer to them using
|
|
8
|
+
# `file.html` in your ng-routes.
|
|
9
|
+
config.patch_sprockets_to_use_html_extension = true
|
|
10
|
+
|
|
11
|
+
# This disables individual precompilation of HTML files in assets/.
|
|
12
|
+
# By default Rang injects them into $templateCache instead.
|
|
13
|
+
config.disable_html_precompilation = true
|
|
14
|
+
|
|
15
|
+
# Name of folder within app/assets to use for collected assets.
|
|
16
|
+
config.frontend_assets_directory = 'frontend'
|
|
17
|
+
|
|
18
|
+
# Disable { and } as Slim delimiters. This means you won't get tripped up when
|
|
19
|
+
# you use them in Angular, e.g.
|
|
20
|
+
# p {{post.title}}
|
|
21
|
+
# But you can't do this:
|
|
22
|
+
# a{href="#"}
|
|
23
|
+
config.remove_angular_delims_from_slim = true
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Rang
|
|
2
|
+
module Teaspoon
|
|
3
|
+
module Generators
|
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
|
5
|
+
desc "Installs teaspoon with sensible defaults for Angular."
|
|
6
|
+
|
|
7
|
+
def add_teaspoon_to_gemfile
|
|
8
|
+
gem_group :development, :test do
|
|
9
|
+
gem "teaspoon", "~> 0.8.0"
|
|
10
|
+
gem "phantomjs", "~> 1.9.0"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def add_angular_mocks_to_gemfile
|
|
15
|
+
generate "rang:bower:add", "angular-mocks '~> 1.2.0' quiet"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def bundle_install
|
|
19
|
+
bundle!
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def teaspoon_install
|
|
23
|
+
generate "teaspoon:install"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_teaspoon_assets_hack
|
|
27
|
+
inject_into_file "spec/teaspoon_env.rb", before: "Teaspoon.configure do |config|" do
|
|
28
|
+
"# Fix for https://github.com/modeset/teaspoon/issues/197\n" +
|
|
29
|
+
"Rails.application.config.assets.debug = false\n\n"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_matcher
|
|
34
|
+
inject_into_file "spec/teaspoon_env.rb", after: /#suite\.matcher =.*$/ do
|
|
35
|
+
"\n suite.matcher = \"{spec/javascripts,app/assets}/**/*[_.]spec.{js,js.coffee,coffee}\"\n"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def require_angular_mocks
|
|
40
|
+
inject_into_file "spec/javascripts/spec_helper.js", before: /\/\/= require application/ do
|
|
41
|
+
"//= require angular\n" +
|
|
42
|
+
"//= require angular-mocks\n"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def inform_of_actions
|
|
47
|
+
say "\n\n ****** \n\n"
|
|
48
|
+
say "\nTeaspoon is installed, you can run `teaspoon` or visit `/teaspoon` to run tests.", :green
|
|
49
|
+
say "Jasmine & angular-mocks are included.\n\n", :green
|
|
50
|
+
say "You can put your specs alongside your JS like this:\n\n", :cyan
|
|
51
|
+
say " |-- posts/\n" +
|
|
52
|
+
" | |-- posts_controller.js\n" +
|
|
53
|
+
" | |-- posts_controller.spec.js\n\n"
|
|
54
|
+
say "Or inside spec/javascripts, as you prefer.", :cyan
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def inform_about_better_errors
|
|
58
|
+
if Util.gem_present? 'better_errors'
|
|
59
|
+
say "\nNote: the better_errors gem prevents ruby exceptions being " +
|
|
60
|
+
"reported when running `teaspoon`.", :cyan
|
|
61
|
+
say "See: https://github.com/modeset/teaspoon/issues/120\n\n"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def bundle!
|
|
68
|
+
Bundler.with_clean_env do
|
|
69
|
+
run "bundle install"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|