marionette-generators 0.1.2

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: 47978760c732dc934f7f9cac8cad09b0ca570464
4
+ data.tar.gz: 64d7deac3a995acf93e9b3a1757bb23e07a33e1b
5
+ SHA512:
6
+ metadata.gz: ba019730d332cf325ce8a02b79815b3f75c693f392996c895f8e6cc6df8899d5433cd5027847f033725cf0305339d2316eaf9f0069008e010df56efd89b107ce
7
+ data.tar.gz: 981f14d73eb8cf9658e195b8ba632491b32cfe21dbd934aa18677da2befa42f6eda2ea3f01eab3bb81858f7f6d799d4f3ec756c4626e1f32a991c949a7c2a0d3
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at franck@web82.fr. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marionette-generators.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Franck Delage
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Marionette::Generators
2
+
3
+ Marionette Generators provides some Backbone/Marionette generators to build a full Marionette app.
4
+
5
+ It's still in development, so it only provides a starter app for now, and templates are only Slim and Skim.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'marionette-generators'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install marionette-generators
22
+
23
+ ## Usage
24
+
25
+ ### App
26
+
27
+ $ rails g marionette:app NameOfYourApp
28
+
29
+ This will install bower-rails, slim-rails and skim gem, and create a `backbone` folder in app/assets/javascripts with all necessary directories and files. It will also create a `templates` folder in app/assets.
30
+
31
+ Then you should see a welcome message in your browser.
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/marionette-generators. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
47
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "marionette/generators"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates a folder and files structure for a full Marionette app inside a Rails app
3
+
4
+ Example:
5
+ rails generate marionette_app Name_of_app
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,90 @@
1
+ require 'rails/generators'
2
+
3
+ module Marionette
4
+ module Generators
5
+ class AppGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def create_directory_structure
9
+ %w(models collections routers utils views).each do |folder|
10
+ empty_directory "app/assets/javascripts/backbone/#{folder}"
11
+ end
12
+ empty_directory "app/assets/templates"
13
+ end
14
+
15
+ def add_backbone_via_bower
16
+ gem 'bower-rails'
17
+ bundle_install
18
+ generate "bower_rails:initialize"
19
+ append_to_file "Bowerfile", bower_data, after: "for more options\n"
20
+ rake 'bower:install'
21
+ rake 'bower:clean'
22
+ end
23
+
24
+ def create_files
25
+ gem 'skim'
26
+ bundle_install
27
+ backbone = "app/assets/javascripts/backbone"
28
+ template "app/app.js.coffee", "#{backbone}/#{file_name}.js.coffee"
29
+ template "app/layout.jst.skim", "app/assets/templates/layouts/layout.jst.skim"
30
+ template "app/logger.js.coffee", "#{backbone}/utils/logger.js.coffee"
31
+ template "app/defaults.js.coffee", "#{backbone}/utils/defaults.js.coffee"
32
+ template "app/config.js.coffee", "#{backbone}/config.js.coffee"
33
+ template "app/layout.js.coffee", "#{backbone}/views/layouts/layout.js.coffee"
34
+ template "app/app_router.js.coffee", "#{backbone}/routers/app_router.js.coffee"
35
+ template "app/application.html.slim", "app/views/layouts/application.html.slim"
36
+ end
37
+
38
+ def add_app_to_index_view
39
+ gem 'slim-rails'
40
+ bundle_install
41
+ routes = File.read "config/routes.rb"
42
+ home = routes.match(/root to: '([a-z_]+)\#index'/).try :captures
43
+ home = home.first
44
+ File.delete "app/views/#{home}/index.html.erb" if File.exist? "app/views/#{home}/index.html.erb"
45
+ File.delete "app/views/#{home}/index.html.haml" if File.exist? "app/views/#{home}/index.html.haml"
46
+ template "app/index.html.slim", "app/views/#{home}/index.html.slim"
47
+ end
48
+
49
+ def include_js
50
+ gsub_file "app/assets/javascripts/application.js", "//= require_tree .", app_js_data
51
+ inject_into_file "app/assets/javascripts/application.js", "//= require backbone/#{name.downcase}\n", after: "require marionette/lib/core/backbone.marionette\n"
52
+ end
53
+
54
+ private
55
+ def bundle_install
56
+ Bundler.with_clean_env do
57
+ run "bundle install"
58
+ end
59
+ end
60
+
61
+ def bower_data
62
+ <<RUBY
63
+ asset 'console.style'
64
+ asset 'backbone'
65
+ asset 'marionette'
66
+ RUBY
67
+ end
68
+
69
+ def app_js_data
70
+ <<RUBY
71
+ //= require console.style/console.style
72
+ //= require skim
73
+ //= require underscore/underscore
74
+ //= require backbone/backbone
75
+ //= require backbone.wreqr/lib/backbone.wreqr
76
+ //= require backbone.babysitter/lib/backbone.babysitter
77
+ //= require marionette/lib/core/backbone.marionette
78
+ //= require_tree ../templates
79
+ //= require ./backbone/config
80
+ //= require_tree ./backbone/utils
81
+ //= require_tree ./backbone/models
82
+ //= require_tree ./backbone/collections
83
+ //= require_tree ./backbone/views
84
+ //= require_tree ./backbone/routers
85
+ RUBY
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,20 @@
1
+ @<%= name.capitalize %> = do (Backbone, Marionette) ->
2
+
3
+ App = new Marionette.Application
4
+
5
+ App.Routers = {}
6
+ App.Views = {}
7
+ App.Collections = {}
8
+ App.Models = {}
9
+ App.Utils = {}
10
+
11
+ App.on 'before:start', ->
12
+ new <%= name.capitalize %>.Utils.Defaults
13
+ new <%= name.capitalize %>.Routers.AppRouter
14
+
15
+ App.on 'start', ->
16
+ if Backbone.history
17
+ Backbone.history.start
18
+ pushState: true
19
+
20
+ App
@@ -0,0 +1,14 @@
1
+ class <%= name.capitalize %>.Routers.AppRouter extends Backbone.Marionette.AppRouter
2
+
3
+ routes:
4
+ '': 'index'
5
+
6
+ initialize: ->
7
+ @logger = new <%= name.capitalize %>.Utils.Logger
8
+ @logger.router 'Initialize Backbone router'
9
+ @layoutView = new <%= name.capitalize %>.Views.Layout
10
+ <%= name.capitalize %>.rootView = @layoutView
11
+ <%= name.capitalize %>.rootView.render()
12
+
13
+ index: ->
14
+ @logger.router 'Call index action'
@@ -0,0 +1,12 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta[name="viewport" content="width=device-width, initial-scale=1.0"]
5
+ title
6
+ = content_for?(:title) ? yield(:title) : '<%= name.capitalize %>'
7
+ meta name="description" content="#{content_for?(:description) ? yield(:description) : '<%= name.capitalize %>'}"
8
+ == stylesheet_link_tag "application", :media => 'all', 'data-turbolinks-track' => true
9
+ == javascript_include_tag 'application', 'data-turbolinks-track' => true
10
+ == csrf_meta_tags
11
+ body
12
+ == yield
@@ -0,0 +1 @@
1
+ <%= name.capitalize %>.module 'Config', (Config, <%= name.capitalize %>, Backbone, Marionnette, $, _)->
@@ -0,0 +1,3 @@
1
+ class <%= name.capitalize %>.Utils.Defaults extends Backbone.View
2
+
3
+ initialize: ->
@@ -0,0 +1,3 @@
1
+ #frontend-app
2
+ javascript:
3
+ $(function() { <%= name.capitalize %>.start(); });
@@ -0,0 +1,12 @@
1
+ class <%= name.capitalize %>.Views.Layout extends Backbone.Marionette.LayoutView
2
+
3
+ template: JST['layouts/layout']
4
+ el: '#frontend-app'
5
+
6
+ # regions:
7
+
8
+ initialize: ->
9
+ @logger = new <%= name.capitalize %>.Utils.Logger
10
+
11
+ onRender: ->
12
+ @logger.view 'Rendering main layout view'
@@ -0,0 +1 @@
1
+ | Hello there, I'm the <%= name.capitalize %> Marionette app !
@@ -0,0 +1,18 @@
1
+ class <%= name.capitalize %>.Utils.Logger extends Backbone.View
2
+
3
+ initialize: ->
4
+
5
+ router: (text)->
6
+ prefix = console.style.wrap 'router : ', "color:yellow;background-color:magenta;font-style:italic;padding:2px"
7
+ wrap = console.style.wrap text, "color:yellow;background-color:magenta;font-weight:bold;padding:2px"
8
+ console.style prefix + wrap
9
+
10
+ view: (text)->
11
+ prefix = console.style.wrap 'view : ', "color:magenta;background-color:yellow;font-style:italic;padding:2px"
12
+ wrap = console.style.wrap text, "color:magenta;background-color:yellow;font-weight:bold;padding:2px"
13
+ console.style prefix + wrap
14
+
15
+ specific: (text)->
16
+ prefix = console.style.wrap 'specific : ', "color:green;background-color:white;font-style:italic;padding:2px"
17
+ wrap = console.style.wrap text, "color:green;background-color:white;font-weight:bold;padding:2px"
18
+ console.style prefix + wrap
@@ -0,0 +1,5 @@
1
+ module Marionette
2
+ module Generators
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "marionette/generators/version"
2
+
3
+ module Marionette
4
+ module Generators
5
+
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marionette/generators/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marionette-generators"
8
+ spec.version = Marionette::Generators::VERSION
9
+ spec.authors = ["Franck Delage"]
10
+ spec.email = ["franck@web82.fr"]
11
+
12
+ spec.summary = %q{Provides some Backbone/Marionette generators for Rails 4.}
13
+ spec.summary = %q{Provides some Backbone/Marionette generators for Rails 4. Installs assets via Bower with bower-rails gem. For now, only provides a starter app, and only with slim and skim templates.}
14
+ spec.homepage = "https://github.com/franckdelage/marionette-generators"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+
26
+ spec.add_runtime_dependency "railties", ">= 3.1.0"
27
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marionette-generators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Franck Delage
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: railties
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ description:
70
+ email:
71
+ - franck@web82.fr
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/generators/marionette/app/USAGE
87
+ - lib/generators/marionette/app/app_generator.rb
88
+ - lib/generators/marionette/app/templates/app/app.js.coffee
89
+ - lib/generators/marionette/app/templates/app/app_router.js.coffee
90
+ - lib/generators/marionette/app/templates/app/application.html.slim
91
+ - lib/generators/marionette/app/templates/app/config.js.coffee
92
+ - lib/generators/marionette/app/templates/app/defaults.js.coffee
93
+ - lib/generators/marionette/app/templates/app/index.html.slim
94
+ - lib/generators/marionette/app/templates/app/layout.js.coffee
95
+ - lib/generators/marionette/app/templates/app/layout.jst.skim
96
+ - lib/generators/marionette/app/templates/app/logger.js.coffee
97
+ - lib/marionette/generators.rb
98
+ - lib/marionette/generators/version.rb
99
+ - marionette-generators.gemspec
100
+ homepage: https://github.com/franckdelage/marionette-generators
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.5.1
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Provides some Backbone/Marionette generators for Rails 4. Installs assets
124
+ via Bower with bower-rails gem. For now, only provides a starter app, and only with
125
+ slim and skim templates.
126
+ test_files: []