sprangular_cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +45 -0
  6. data/Rakefile +1 -0
  7. data/bin/sprangular +2 -0
  8. data/lib/sprangular_cli.rb +25 -0
  9. data/lib/sprangular_cli/extension.rb +52 -0
  10. data/lib/sprangular_cli/installer.rb +200 -0
  11. data/lib/sprangular_cli/templates/extension/CONTRIBUTING.md +57 -0
  12. data/lib/sprangular_cli/templates/extension/Gemfile +12 -0
  13. data/lib/sprangular_cli/templates/extension/LICENSE +26 -0
  14. data/lib/sprangular_cli/templates/extension/README.md +47 -0
  15. data/lib/sprangular_cli/templates/extension/Rakefile +21 -0
  16. data/lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%.js.tt +4 -0
  17. data/lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/controllers/test.coffee.tt +3 -0
  18. data/lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/module.coffee.tt +1 -0
  19. data/lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/routes.coffee.tt +6 -0
  20. data/lib/sprangular_cli/templates/extension/app/assets/templates/test/index.html.slim +1 -0
  21. data/lib/sprangular_cli/templates/extension/bin/rails.tt +7 -0
  22. data/lib/sprangular_cli/templates/extension/config/locales/en.yml +5 -0
  23. data/lib/sprangular_cli/templates/extension/config/routes.rb +3 -0
  24. data/lib/sprangular_cli/templates/extension/extension.gemspec +33 -0
  25. data/lib/sprangular_cli/templates/extension/gitignore +14 -0
  26. data/lib/sprangular_cli/templates/extension/lib/%file_name%.rb.tt +3 -0
  27. data/lib/sprangular_cli/templates/extension/lib/%file_name%/engine.rb.tt +20 -0
  28. data/lib/sprangular_cli/templates/extension/lib/%file_name%/version.rb.tt +3 -0
  29. data/lib/sprangular_cli/templates/extension/rspec +1 -0
  30. data/lib/sprangular_cli/templates/extension/spec/spec_helper.rb.tt +84 -0
  31. data/lib/sprangular_cli/version.rb +3 -0
  32. data/sprangular_cli.gemspec +24 -0
  33. metadata +119 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 69bec9d37665d84e4846348ec0ddf87ab2c862a0
4
+ data.tar.gz: 6f64b2581b53a74787b9bdef038181493f4b5e87
5
+ SHA512:
6
+ metadata.gz: cff6365ebbeafb39f08be5f894c313607eea35130a4a044f4e2d42a7ae445a2e05d1964cce01619ca08751deb1e88770b64e5dc824c2eeaf885812998aaeedc7
7
+ data.tar.gz: 4e074d94b76e575df802bfd58b1e31784f802751c7d1dd76e94be9cc3fd41b0404d150c1e351bb17d9d3667b34a6d44caa2009060a59a7fb54bda201fff871d4
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ ruby '2.1.5'
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Josh Nussbaum
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Sprangular CLI Utility
2
+
3
+ A tool for creating sprangular extensions and setting up apps.
4
+
5
+ ## Installation
6
+
7
+
8
+ ```shell
9
+ gem install sprangular_cli
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ### Create an extension
15
+
16
+ ```shell
17
+ sprangular extension example
18
+ ```
19
+
20
+ ### Setup an application
21
+
22
+ ```shell
23
+ cd my-rails-app
24
+ sprangular install
25
+ ```
26
+
27
+ ### Show available commands
28
+
29
+ ```shell
30
+ sprangular help
31
+ ```
32
+
33
+ ### Show version
34
+
35
+ ```shell
36
+ sprangular -v
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/sprangular ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sprangular_cli'
@@ -0,0 +1,25 @@
1
+ require "sprangular_cli/version"
2
+ require 'thor'
3
+ require 'thor/group'
4
+
5
+ case ARGV.first
6
+ when nil, 'help', '-h', '--help', '-?'
7
+ puts <<-EOS
8
+ sprangular - a tool for creating sprangular gems
9
+
10
+ version:\t display version (alias: -v, --version)
11
+ help:\t\t display help (alias: -h, --help)
12
+ extension:\t create an extension (arguments: <extension-name>)
13
+ install:\t install sprangular (arguments: <site-name>|.)
14
+ EOS
15
+ when 'version', '-v', '--version'
16
+ puts SprangularCli::VERSION
17
+ when 'extension'
18
+ ARGV.shift
19
+ require 'sprangular_cli/extension'
20
+ SprangularCli::Extension.start
21
+ else
22
+ ARGV.shift
23
+ require 'sprangular_cli/installer'
24
+ SprangularCli::Installer.start
25
+ end
@@ -0,0 +1,52 @@
1
+ module SprangularCli
2
+
3
+ class Extension < Thor::Group
4
+ include Thor::Actions
5
+
6
+ desc "builds a sprangular extension"
7
+ argument :file_name, type: :string, desc: 'rails app_path', default: '.'
8
+
9
+ source_root File.expand_path('../templates/extension', __FILE__)
10
+
11
+ def generate
12
+ use_prefix 'sprangular_'
13
+
14
+ empty_directory file_name
15
+
16
+ directory 'app', "#{file_name}/app"
17
+ directory 'lib', "#{file_name}/lib"
18
+ directory 'bin', "#{file_name}/bin"
19
+
20
+ template 'extension.gemspec', "#{file_name}/#{file_name}.gemspec"
21
+ template 'Gemfile', "#{file_name}/Gemfile"
22
+ template 'gitignore', "#{file_name}/.gitignore"
23
+ template 'LICENSE', "#{file_name}/LICENSE"
24
+ template 'Rakefile', "#{file_name}/Rakefile"
25
+ template 'README.md', "#{file_name}/README.md"
26
+ template 'config/routes.rb', "#{file_name}/config/routes.rb"
27
+ template 'config/locales/en.yml', "#{file_name}/config/locales/en.yml"
28
+ template 'rspec', "#{file_name}/.rspec"
29
+ template 'spec/spec_helper.rb.tt', "#{file_name}/spec/spec_helper.rb"
30
+ end
31
+
32
+ no_tasks do
33
+ def class_name
34
+ Thor::Util.camel_case(file_name)
35
+ end
36
+
37
+ def use_prefix(prefix)
38
+ unless file_name =~ /^#{prefix}/
39
+ @file_name = prefix + Thor::Util.snake_case(file_name)
40
+ end
41
+ end
42
+
43
+ def name_without_prefix
44
+ @file_name.gsub(/^sprangular_/, '')
45
+ end
46
+
47
+ def module_name
48
+ Thor::Util.camel_case(name_without_prefix)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,200 @@
1
+ require 'rbconfig'
2
+ require 'active_support/core_ext/string'
3
+
4
+ module SprangularCli
5
+
6
+ class Installer < Thor::Group
7
+ include Thor::Actions
8
+
9
+ desc 'Creates a new rails project with a spree store'
10
+ argument :app_path, type: :string, desc: 'rails app_path', default: '.'
11
+
12
+ class_option :auto_accept, type: :boolean, aliases: '-A',
13
+ desc: 'Answer yes to all prompts'
14
+
15
+ class_option :skip_install_data, type: :boolean, default: false,
16
+ desc: 'Skip running migrations and loading seed and sample data'
17
+
18
+ class_option :version, type: :string, desc: 'Sprangular version to use', default: '0.1.0'
19
+ class_option :spree_version, type: :string, desc: 'Spree version to use', default: '2.4'
20
+
21
+ class_option :edge, type: :boolean
22
+
23
+ class_option :path, type: :string, desc: 'Spree gem path'
24
+ class_option :git, type: :string, desc: 'Spree gem git url'
25
+ class_option :ref, type: :string, desc: 'Spree gem git ref'
26
+ class_option :branch, type: :string, desc: 'Spree gem git branch'
27
+ class_option :tag, type: :string, desc: 'Spree gem git tag'
28
+
29
+ def verify_image_magick
30
+ unless image_magick_installed?
31
+ say "Image magick must be installed."
32
+ exit 1
33
+ end
34
+ end
35
+
36
+ def verify_rails
37
+ create_rails_app unless rails_project?
38
+ end
39
+
40
+ def prepare_options
41
+ @spree_gem_options = {}
42
+
43
+ if options[:edge] || options[:branch]
44
+ @spree_gem_options[:github] = 'spree/spree'
45
+ elsif options[:path]
46
+ @spree_gem_options[:path] = options[:path]
47
+ elsif options[:git]
48
+ @spree_gem_options[:git] = options[:git]
49
+ @spree_gem_options[:ref] = options[:ref] if options[:ref]
50
+ @spree_gem_options[:tag] = options[:tag] if options[:tag]
51
+ elsif options[:spree_version]
52
+ @spree_gem_options[:version] = options[:spree_version]
53
+ else
54
+ version = '2.4'
55
+ @spree_gem_options[:version] = version.to_s
56
+ end
57
+
58
+ @spree_gem_options[:branch] = options[:branch] if options[:branch]
59
+ end
60
+
61
+ def ask_questions
62
+ @install_default_gateways = ask_with_default('Would you like to install the default gateways? (Recommended)')
63
+ @install_default_auth = ask_with_default('Would you like to install the default authentication system?')
64
+
65
+ if @install_default_auth
66
+ @user_class = "Spree::User"
67
+ else
68
+ @user_class = ask("What is the name of the class representing users within your application? [User]")
69
+ if @user_class.blank?
70
+ @user_class = "User"
71
+ end
72
+ end
73
+
74
+ if options[:skip_install_data]
75
+ @run_migrations = false
76
+ @load_seed_data = false
77
+ @load_sample_data = false
78
+ else
79
+ @run_migrations = ask_with_default('Would you like to run the migrations?')
80
+ if @run_migrations
81
+ @load_seed_data = ask_with_default('Would you like to load the seed data?')
82
+ @load_sample_data = ask_with_default('Would you like to load the sample data?')
83
+ else
84
+ @load_seed_data = false
85
+ @load_sample_data = false
86
+ end
87
+ end
88
+ end
89
+
90
+ def add_gems
91
+ inside @app_path do
92
+ prepend_file 'Gemfile', "source 'https://rails-assets.org'\n", verbose: false
93
+
94
+ gem 'spree_core', @spree_gem_options
95
+ gem 'spree_api', @spree_gem_options
96
+ gem 'spree_backend', @spree_gem_options
97
+ gem 'spree_sample', @spree_gem_options
98
+
99
+ if @install_default_gateways && @spree_gem_options[:branch]
100
+ gem :spree_gateway, github: 'spree/spree_gateway', branch: @spree_gem_options[:branch]
101
+ elsif @install_default_gateways
102
+ gem :spree_gateway, github: 'spree/spree_gateway', branch: '2-4-stable'
103
+ end
104
+
105
+ if @install_default_auth && @spree_gem_options[:branch]
106
+ gem :spree_auth_devise, github: 'spree/spree_auth_devise', branch: @spree_gem_options[:branch]
107
+ elsif @install_default_auth
108
+ gem :spree_auth_devise, github: 'spree/spree_auth_devise', branch: '2-4-stable'
109
+ end
110
+
111
+ if options[:edge]
112
+ gem :sprangular, github: 'sprangular/sprangular'
113
+ else
114
+ gem :sprangular, version: options[:version]
115
+ end
116
+
117
+ run 'bundle install', capture: true
118
+ end
119
+ end
120
+
121
+ def initialize_spree
122
+ spree_options = []
123
+ spree_options << "--migrate=#{@run_migrations}"
124
+ spree_options << "--seed=#{@load_seed_data}"
125
+ spree_options << "--sample=#{@load_sample_data}"
126
+ spree_options << "--user_class=#{@user_class}"
127
+ spree_options << "--auto_accept" if options[:auto_accept]
128
+
129
+ inside @app_path do
130
+ run "rails generate spree:install #{spree_options.join(' ')}", verbose: false
131
+ end
132
+ end
133
+
134
+ def initialize_sprangular
135
+ inside @app_path do
136
+ run "rails generate sprangular:install", verbose: false
137
+ end
138
+ end
139
+
140
+ private
141
+
142
+ def gem(name, gem_options={})
143
+ gem_options = gem_options.dup
144
+ say_status :gemfile, name
145
+ parts = ["'#{name}'"]
146
+ parts << ["'#{gem_options.delete(:version)}'"] if gem_options[:version]
147
+ gem_options.each { |key, value| parts << "#{key}: '#{value}'" }
148
+ append_file 'Gemfile', "\ngem #{parts.join(', ')}", verbose: false
149
+ end
150
+
151
+ def ask_with_default(message, default = 'yes')
152
+ return true if options[:auto_accept]
153
+
154
+ valid = false
155
+ until valid
156
+ response = ask "#{message} (yes/no) [#{default}]"
157
+ response = default if response.empty?
158
+ valid = (response =~ /\Ay(?:es)?|no?\Z/i)
159
+ end
160
+ response.downcase[0] == ?y
161
+ end
162
+
163
+ def ask_string(message, default, valid_regex = /\w/)
164
+ return default if options[:auto_accept]
165
+ valid = false
166
+ until valid
167
+ response = ask "#{message} [#{default}]"
168
+ response = default if response.empty?
169
+ valid = (valid_regex === response)
170
+ end
171
+ response
172
+ end
173
+
174
+ def create_rails_app
175
+ say :create, @app_path
176
+
177
+ rails_cmd = "rails new #{@app_path} --skip-test-unit --skip-bundle"
178
+ rails_cmd << " -m #{options[:template]}" if options[:template]
179
+ rails_cmd << " -d #{options[:database]}" if options[:database]
180
+ run(rails_cmd)
181
+ end
182
+
183
+ def rails_project?
184
+ File.exists? File.join(@app_path, 'bin', 'rails')
185
+ end
186
+
187
+ def image_magick_installed?
188
+ cmd = 'identify -version'
189
+ if RUBY_PLATFORM =~ /mingw|mswin/ #windows
190
+ cmd += " >nul"
191
+ else
192
+ cmd += " >/dev/null"
193
+ end
194
+ # true if command executed succesfully
195
+ # false for non zero exit status
196
+ # nil if command execution fails
197
+ system(cmd)
198
+ end
199
+ end
200
+ end
@@ -0,0 +1,57 @@
1
+ # How to contribute
2
+
3
+ Third-party patches are essential to any great open source project. We want
4
+ to keep it as easy as possible to contribute changes that get things working
5
+ in your environment. There are a few guidelines that we need contributors to
6
+ follow so that we can have a chance of keeping on top of things.
7
+
8
+ ## Getting Started
9
+
10
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
11
+ * Submit a ticket for your issue, assuming one does not already exist.
12
+ * Clearly describe the issue including steps to reproduce when it is a bug.
13
+ * Make sure you fill in the earliest version that you know has the issue.
14
+ * Fork the repository on GitHub
15
+
16
+ ## Making Changes
17
+
18
+ * Create a topic branch from where you want to base your work.
19
+ * This is usually the master branch.
20
+ * Only target release branches if you are certain your fix must be on that
21
+ branch.
22
+ * To quickly create a topic branch based on master; `git branch
23
+ fix/master/my_contribution master` then checkout the new branch with `git
24
+ checkout fix/master/my_contribution`. Please avoid working directly on the
25
+ `master` branch.
26
+ * Make commits of logical units.
27
+ * Check for unnecessary whitespace with `git diff --check` before committing.
28
+ * Make sure your commit messages are in the proper format.
29
+
30
+ ````
31
+ (#99999) Make the example in CONTRIBUTING imperative and concrete
32
+
33
+ Without this patch applied the example commit message in the CONTRIBUTING
34
+ document is not a concrete example. This is a problem because the
35
+ contributor is left to imagine what the commit message should look like
36
+ based on a description rather than an example. This patch fixes the
37
+ problem by making the example concrete and imperative.
38
+
39
+ The first line is a real life imperative statement with a ticket number
40
+ from our issue tracker. The body describes the behavior without the patch,
41
+ why this is a problem, and how the patch fixes the problem when applied.
42
+ ````
43
+
44
+ * Make sure you have added the necessary tests for your changes.
45
+ * Run _all_ the tests to assure nothing else was accidentally broken.
46
+
47
+ ## Submitting Changes
48
+
49
+ * Push your changes to a topic branch in your fork of the repository.
50
+ * Submit a pull request to the extensions repository.
51
+ * Update any Github issues to mark that you have submitted code and are ready for it to be reviewed.
52
+ * Include a link to the pull request in the ticket
53
+
54
+ # Additional Resources
55
+
56
+ * [General GitHub documentation](http://help.github.com/)
57
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
@@ -0,0 +1,12 @@
1
+ ruby "2.1.5"
2
+
3
+ source "https://rubygems.org"
4
+ source "https://rails-assets.org"
5
+
6
+ gem 'spree', github: 'spree/spree', branch: '2-4-stable'
7
+ gem 'sprangular', github: 'sprangular/sprangular'
8
+
9
+ # Provides basic authentication functionality for testing parts of your engine
10
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-4-stable'
11
+
12
+ gemspec
@@ -0,0 +1,26 @@
1
+ Copyright (c) <%= Time.now.year %> [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,47 @@
1
+ <%= class_name %>
2
+ <%= "=" * class_name.size %>
3
+
4
+ Introduction goes here.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add <%= file_name %> to your Gemfile:
10
+
11
+ ```ruby
12
+ gem '<%= file_name %>'
13
+ ```
14
+
15
+ Bundle your dependencies:
16
+
17
+ ```shell
18
+ bundle
19
+ ```
20
+
21
+ Add javascript assets to your app:
22
+
23
+ ```javascript
24
+ // in app/assets/javascripts/application.js
25
+
26
+ //= require sprangular/<%= name_without_prefix %>
27
+ ```
28
+
29
+ Add angular module dependency to your host app:
30
+
31
+ ```coffeescript
32
+ # in app/assets/javascripts/sprangular/host.coffee
33
+
34
+ angular.module 'YourAppName', ['Sprangular', 'Sprangular.<%= module_name %>']
35
+ ```
36
+
37
+ Testing
38
+ -------
39
+
40
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
41
+
42
+ ```shell
43
+ bundle
44
+ bundle exec rake
45
+ ```
46
+
47
+ Copyright (c) <%= Time.now.year %> [name of extension creator], released under the New BSD License
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = '<%=file_name%>'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,4 @@
1
+ //= require ./<%= name_without_prefix %>/module
2
+ //= require ./<%= name_without_prefix %>/routes
3
+ //= require_tree ./<%= name_without_prefix %>/controllers
4
+ //= require_tree ./<%= name_without_prefix %>/services
@@ -0,0 +1,3 @@
1
+ angular.module('Sprangular.<%= module_name %>')
2
+ .controller 'TestCtrl', ($scope) ->
3
+ $scope.message = "Hello World!"
@@ -0,0 +1 @@
1
+ angular.module('Sprangular.<%= module_name %>', ['Sprangular'])
@@ -0,0 +1,6 @@
1
+ angular.module('Sprangular.<%= module_name %>')
2
+ .config ($routeProvider) ->
3
+
4
+ $routeProvider.when '/test',
5
+ controller: 'TestCtrl'
6
+ templateUrl: 'test/index.html'
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/<%= file_name -%>/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: UTF-8
2
+ require_relative "lib/<%= file_name %>/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.name = '<%= file_name %>'
7
+ s.version = <%= class_name %>::VERSION
8
+ s.summary = 'TODO: Add gem summary here'
9
+ s.description = 'TODO: Add (optional) gem description here'
10
+ s.required_ruby_version = '>= 1.9.3'
11
+
12
+ # s.author = 'You'
13
+ # s.email = 'you@example.com'
14
+ # s.homepage = 'https://github.com/owner/<%= file_name %>'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_path = 'lib'
19
+ s.requirements << 'none'
20
+
21
+ s.add_dependency 'sprangular'
22
+
23
+ s.add_development_dependency 'capybara', '~> 2.4'
24
+ s.add_development_dependency 'coffee-rails'
25
+ s.add_development_dependency 'database_cleaner'
26
+ s.add_development_dependency 'factory_girl', '~> 4.5'
27
+ s.add_development_dependency 'ffaker'
28
+ s.add_development_dependency 'rspec-rails', '~> 3.1'
29
+ s.add_development_dependency 'sass-rails', '~> 4.0.2'
30
+ s.add_development_dependency 'selenium-webdriver'
31
+ s.add_development_dependency 'simplecov'
32
+ s.add_development_dependency 'sqlite3'
33
+ end
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
@@ -0,0 +1,3 @@
1
+ require 'spree_core'
2
+ require 'sprangular'
3
+ require '<%=file_name%>/engine'
@@ -0,0 +1,20 @@
1
+ module <%= class_name %>
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name '<%= file_name %>'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module <%= class_name %>
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,84 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories and other useful helpers defined in spree_core.
27
+ require 'spree/testing_support/authorization_helpers'
28
+ require 'spree/testing_support/capybara_ext'
29
+ require 'spree/testing_support/controller_requests'
30
+ require 'spree/testing_support/factories'
31
+ require 'spree/testing_support/url_helpers'
32
+
33
+ RSpec.configure do |config|
34
+ config.include FactoryGirl::Syntax::Methods
35
+
36
+ # Infer an example group's spec type from the file location.
37
+ config.infer_spec_type_from_file_location!
38
+
39
+ # == URL Helpers
40
+ #
41
+ # Allows access to Spree's routes in specs:
42
+ #
43
+ # visit spree.admin_path
44
+ # current_path.should eql(spree.products_path)
45
+ config.include Spree::TestingSupport::UrlHelpers
46
+
47
+ # == Mock Framework
48
+ #
49
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
50
+ #
51
+ # config.mock_with :mocha
52
+ # config.mock_with :flexmock
53
+ # config.mock_with :rr
54
+ config.mock_with :rspec
55
+ config.color = true
56
+
57
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
58
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
59
+
60
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
61
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
62
+ # to setup a test will be unavailable to the browser, which runs under a separate server instance.
63
+ config.use_transactional_fixtures = false
64
+
65
+ # Ensure Suite is set to use transactions for speed.
66
+ config.before :suite do
67
+ DatabaseCleaner.strategy = :transaction
68
+ DatabaseCleaner.clean_with :truncation
69
+ end
70
+
71
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
72
+ config.before :each do
73
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
74
+ DatabaseCleaner.start
75
+ end
76
+
77
+ # After each spec clean the database.
78
+ config.after :each do
79
+ DatabaseCleaner.clean
80
+ end
81
+
82
+ config.fail_fast = ENV['FAIL_FAST'] || false
83
+ config.order = "random"
84
+ end
@@ -0,0 +1,3 @@
1
+ module SprangularCli
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/sprangular_cli/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "sprangular_cli"
6
+ spec.version = SprangularCli::VERSION
7
+ spec.authors = ["Josh Nussbaum"]
8
+ spec.email = ["joshnuss@gmail.com"]
9
+ spec.description = %q{Create sprangular extensions}
10
+ spec.summary = %q{Tool for creating sprangular extensions}
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = '>= 2.0.0'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "thor"
21
+ spec.add_dependency "activesupport"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprangular_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nussbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ description: Create sprangular extensions
56
+ email:
57
+ - joshnuss@gmail.com
58
+ executables:
59
+ - sprangular
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/sprangular
69
+ - lib/sprangular_cli.rb
70
+ - lib/sprangular_cli/extension.rb
71
+ - lib/sprangular_cli/installer.rb
72
+ - lib/sprangular_cli/templates/extension/CONTRIBUTING.md
73
+ - lib/sprangular_cli/templates/extension/Gemfile
74
+ - lib/sprangular_cli/templates/extension/LICENSE
75
+ - lib/sprangular_cli/templates/extension/README.md
76
+ - lib/sprangular_cli/templates/extension/Rakefile
77
+ - lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%.js.tt
78
+ - lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/controllers/test.coffee.tt
79
+ - lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/module.coffee.tt
80
+ - lib/sprangular_cli/templates/extension/app/assets/javascripts/sprangular/%name_without_prefix%/routes.coffee.tt
81
+ - lib/sprangular_cli/templates/extension/app/assets/templates/test/index.html.slim
82
+ - lib/sprangular_cli/templates/extension/bin/rails.tt
83
+ - lib/sprangular_cli/templates/extension/config/locales/en.yml
84
+ - lib/sprangular_cli/templates/extension/config/routes.rb
85
+ - lib/sprangular_cli/templates/extension/extension.gemspec
86
+ - lib/sprangular_cli/templates/extension/gitignore
87
+ - lib/sprangular_cli/templates/extension/lib/%file_name%.rb.tt
88
+ - lib/sprangular_cli/templates/extension/lib/%file_name%/engine.rb.tt
89
+ - lib/sprangular_cli/templates/extension/lib/%file_name%/version.rb.tt
90
+ - lib/sprangular_cli/templates/extension/rspec
91
+ - lib/sprangular_cli/templates/extension/spec/spec_helper.rb.tt
92
+ - lib/sprangular_cli/version.rb
93
+ - sprangular_cli.gemspec
94
+ homepage: ''
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.0.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Tool for creating sprangular extensions
118
+ test_files: []
119
+ has_rdoc: