creategem 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a615438a0c6587189e0ac5ac2060a7934d85ce0
4
- data.tar.gz: 5afe9d4d400cdf2adb8a8178554dc63101c98649
3
+ metadata.gz: da0e6aaab1aa8f7f4cfd9905ace49c57cb2cf3ee
4
+ data.tar.gz: 1cae1883432320b29c9ea5e5c7be003edcc57c2f
5
5
  SHA512:
6
- metadata.gz: 4b0f00472c0e804e1f5fd6ec022e4ced5ee33d97d80bae8508910302087bba559e4f710f0e73bfdbddfda899e3b7b57c4c75554974b0e0b5ce630d071f1fa76e
7
- data.tar.gz: 46d49e11442249ab731275585dab6337d512e5cdd34ebd940d850e5a05a38e03a57da3afe37b2c6dad82039a3854a29ed917241b89a5a99b953334bd76e4a262
6
+ metadata.gz: 847852e1328ebe466546d26b026fb769357c60ca5c3eed14381946f7d0d246d8ca20988d294ac6baf943c3b0577926b902f295159c1a722f3f6cf2566f453ebc
7
+ data.tar.gz: 30a7cce5fc68da0d0f7ef9415b2532bb15f1d1cc01d2aaa40c64061d5d6ca76bd55a0acbf6b23dbcc673956bc3a7379debb90db1c1c62e97f7eb23ff4e881115
data/README.md CHANGED
@@ -20,10 +20,11 @@ Similar to what Bundler's bundle gem command does, this gem generates a scaffold
20
20
 
21
21
  Features:
22
22
  - automatically creates local and remote git repository (github or bitbucket) for your gem
23
+ - option to create private github and bitbucket repositories
23
24
  - automatically release patches, minor and major versions without having to manually increase versions (thanks to [gem-release](https://github.com/svenfuchs/gem-release))
24
25
  - executable based on [Thor](http://whatisthor.com) (can be omited with --no-executable)
25
26
  - test infrastructure based on minitest and minitest-reporters
26
- - release to rubygems.org or to private geminabox gem server
27
+ - release to rubygems.org or to a private geminabox gem server
27
28
  - readme with badges for travis, codeclimate, coveralls, etc. for public projects (like the badges you see above)
28
29
 
29
30
 
@@ -34,22 +35,22 @@ Features:
34
35
 
35
36
  ## Usage
36
37
 
37
- $ creategem gem GEM_NAME [--private] [--no-executable]
38
+ $ creategem gem GEM_NAME [--private] [--no-executable] [--bitbucket]
38
39
 
39
40
  When called without any options it is assumed that you want a gem with an executable and hosted in a public github git repository, and released to rubygems.org.
40
41
 
41
- During the creation you will be asked for your github user name (only the first time, as the user name is saved in your git global config). You will also be asked to enter your github password when the remote repository is created for you with the github rest api.
42
+ During the creation you will be asked for your github or bitbucket user name (only the first time, as the user name is saved in your git global config). You will also be asked to enter your github or bitbucket password when the remote repository is created for you with the rest api.
42
43
 
43
- When you use the `--private` option a bitbucket repository is created for the gem and on release the gem is pushed to a private Geminabox server.
44
-
45
- During the creation you will be asked for your bitbucket user name and the url of your geminabox gem server (only the first time, as the user name and the gem server url are saved in your git global config). You will also be asked to enter your bitbucket password when the remote repository is created for you with the bitbucket rest api.
44
+ When you use the `--private` option, a private github or bitbucket repository is created for the gem and on release the gem is pushed to a private geminabox server. During the creation you will be asked for the url of your geminabox gem server (only the first time, as the gem server url is saved in your git global config).
46
45
 
46
+ When you specify the `--bitbucket` option, a bitbucket repository is created instead of github (default)
47
+
47
48
  Per default a gem is created with an executable based on Thor, but you can omit the executable with the option `--no-executable`.
48
49
 
49
50
  After you create the gem, edit your gemspec and change the summary and the description, commit the changes to git and invoke `rake release_patch` and your gem is being released.
50
51
 
51
52
 
52
- $ creategem plugin GEM_NAME [--engine] [--mountable] [--private] [--executable]
53
+ $ creategem plugin GEM_NAME [--engine] [--mountable] [--private] [--bitbucket] [--executable]
53
54
 
54
55
  `creategem plugin` creates a rails plugin. You can also specify if the plugin should be an engine (`--engine`) or a mountable engine (`--mountable`).
55
56
 
data/lib/creategem/cli.rb CHANGED
@@ -19,6 +19,8 @@ module Creategem
19
19
  desc "gem NAME", "Creates a new gem with a given NAME with Github git repository; Options: --private (Bitbucket/Geminabox), --no-executable"
20
20
  option :private, type: :boolean, default: false, desc: "When true, Bitbucket and Geminabox are used, otherwise Github and Rubygems are used (default)"
21
21
  option :executable, type: :boolean, default: true, desc: "When true, gem with executable is created"
22
+ option :github, type: :boolean, default: true, desc: "When true, Github remote repository is created (default)"
23
+ option :bitbucket, type: :boolean, default: false, desc: "When true, Bitbucket remote repository is created"
22
24
  def gem(gem_name)
23
25
  create_gem_scaffold(gem_name)
24
26
  initialize_repository(gem_name)
@@ -29,6 +31,8 @@ module Creategem
29
31
  option :engine, type: :boolean, default: false, desc: "When true, gem with rails engine is created"
30
32
  option :mountable, type: :boolean, default: false, desc: "When true, gem with mountable rails engine is created"
31
33
  option :executable, type: :boolean, default: false, desc: "When true, gem with executable is created"
34
+ option :github, type: :boolean, default: true, desc: "When true, Github remote repository is created (default)"
35
+ option :bitbucket, type: :boolean, default: false, desc: "When true, Bitbucket remote repository is created"
32
36
  def plugin(gem_name)
33
37
  @plugin = true
34
38
  @engine = options[:engine] || options[:mountable]
@@ -47,11 +51,12 @@ module Creategem
47
51
  @gem_name = gem_name
48
52
  @class_name = Thor::Util.camel_case(gem_name.gsub("-", "_"))
49
53
  @executable = options[:executable]
50
- @vendor = options[:private] ? :bitbucket : :github
54
+ @vendor = options[:bitbucket] ? :bitbucket : :github
51
55
  @repository = Creategem::Repository.new(vendor: @vendor,
56
+ private: options[:private],
52
57
  user: git_repository_user_name(@vendor),
53
58
  name: gem_name,
54
- gem_server_url: gem_server_url(@vendor))
59
+ gem_server_url: gem_server_url(options[:private]))
55
60
  directory "gem_scaffold", gem_name
56
61
  if @executable
57
62
  directory "executable_scaffold", gem_name
data/lib/creategem/git.rb CHANGED
@@ -14,9 +14,9 @@ module Creategem
14
14
  def create_remote_git_repository(repository)
15
15
  say "Create remote #{repository.vendor} repository", :green
16
16
  if repository.github?
17
- run "curl -u '#{repository.user}' https://api.github.com/user/repos -d '{\"name\":\"#{repository.name}\"}'"
18
- else
19
- run "curl --request POST --user #{repository.user} https://api.bitbucket.org/1.0/repositories/ --data name=#{repository.name} --data scm=git --data is_private=true"
17
+ run "curl -u '#{repository.user}' https://api.github.com/user/repos -d '{\"name\":\"#{repository.name}\", \"private\":\"#{repository.private}\"}'"
18
+ else # bitbucket
19
+ run "curl --request POST --user #{repository.user} https://api.bitbucket.org/1.0/repositories/ --data name=#{repository.name} --data scm=git --data is_private=#{repository.private}"
20
20
  end
21
21
  run "git remote add origin #{repository.origin}"
22
22
  say "Push initial commit to remote #{repository.vendor} repository", :green
@@ -33,10 +33,8 @@ module Creategem
33
33
  user
34
34
  end
35
35
 
36
- def gem_server_url(vendor)
37
- if vendor == :github
38
- "https://rubygems.org"
39
- else
36
+ def gem_server_url(private)
37
+ if private
40
38
  git_config_key = "creategem.gemserver"
41
39
  url = ::Git.global_config(git_config_key)
42
40
  if url.nil? || url.empty?
@@ -44,6 +42,8 @@ module Creategem
44
42
  ::Git.global_config(git_config_key, url)
45
43
  end
46
44
  url
45
+ else
46
+ "https://rubygems.org"
47
47
  end
48
48
  end
49
49
  end
@@ -5,10 +5,11 @@ module Creategem
5
5
  class Repository
6
6
  REPOSITORIES = { github: "github.com", bitbucket: "bitbucket.org" }
7
7
 
8
- attr_reader :vendor, :name, :user, :user_name, :user_email, :gem_server_url
8
+ attr_reader :vendor, :name, :user, :user_name, :user_email, :gem_server_url, :private
9
9
 
10
10
  def initialize(options)
11
11
  @vendor = options[:vendor]
12
+ @private = options[:private]
12
13
  @name = options[:name]
13
14
  @user = options[:user]
14
15
  @user_name = ::Git.global_config "user.name"
@@ -1,3 +1,3 @@
1
1
  module Creategem
2
- VERSION = '0.4.4'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -35,6 +35,13 @@ Gem::Specification.new do |spec|
35
35
  <% end %>
36
36
  <% if @plugin -%>
37
37
  spec.add_development_dependency "sqlite3"
38
+ spec.add_development_dependency "quiet_assets"
39
+ spec.add_development_dependency "minitest-screenshot-reporter", "~> 0.0.2"
40
+ spec.add_development_dependency "capybara", "~> 2.6.0"
41
+ spec.add_development_dependency "capybara_minitest_spec", "~> 1.0.5"
42
+ spec.add_development_dependency "selenium-webdriver", "~> 2.49.0"
43
+ spec.add_development_dependency "poltergeist", "~> 1.8.1"
44
+ spec.add_development_dependency "database_cleaner", "~> 1.5.2"
38
45
  <% end %>
39
46
  <% if @executable %>
40
47
  spec.add_dependency "thor", "~> 0.19"
@@ -4,9 +4,9 @@
4
4
  /_yardoc/
5
5
  /coverage/
6
6
  /test/coverage/
7
+ /test/reports/
7
8
  /doc/
8
9
  /pkg/
9
- /spec/reports/
10
10
  /tmp/
11
11
 
12
12
  <% if @plugin -%>
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in <%= @gem_name %>.gemspec
4
4
  gemspec
5
+
6
+ # path '../' # uncomment to use unreleased gem dependencies from same directory
@@ -9,7 +9,15 @@ require '<%= @gem_name %>'
9
9
  require 'minitest/autorun'
10
10
 
11
11
  require 'minitest/reporters'
12
+ <% if @plugin -%>
13
+ require 'minitest/reporters/screenshot_reporter'
14
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new,
15
+ Minitest::Reporters::JUnitReporter.new,
16
+ Minitest::Reporters::ScreenshotReporter.new]
17
+ <% else -%>
12
18
  Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
19
+ <% end -%>
20
+
13
21
  # Filter out Minitest backtrace while allowing backtrace from other libraries to be shown.
14
22
  Minitest.backtrace_filter = Minitest::BacktraceFilter.new
15
23
 
@@ -30,4 +38,58 @@ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
30
38
  ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
31
39
  ActiveSupport::TestCase.fixtures :all
32
40
  end
41
+
42
+ # default test class for unit tests
43
+ class UnitTest < ActiveSupport::TestCase
44
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
45
+ fixtures :all
46
+ end
47
+
48
+ # configure webtests with capybara and poltergeist (headless)
49
+ require 'capybara/rails'
50
+ require 'capybara_minitest_spec'
51
+ require 'capybara/poltergeist'
52
+
53
+ CAPYBARA_WINDOW_SIZE = [1024, 768]
54
+
55
+ if ENV['HEADLESS'] == 'true'
56
+ # headless driver configuration
57
+ Capybara.register_driver :poltergeist do |app|
58
+ poltergeist_options = { debug: false, timeout: 30, js_errors: true, window_size: CAPYBARA_WINDOW_SIZE }
59
+ Capybara::Poltergeist::Driver.new(app, poltergeist_options)
60
+ end
61
+ Capybara.default_driver = :poltergeist
62
+ else
63
+ # chrome browser driver configuration
64
+ Capybara.register_driver :selenium do |app|
65
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
66
+ end
67
+ Capybara.default_driver = :selenium
68
+ Capybara.current_session.driver.browser.manage.window.resize_to CAPYBARA_WINDOW_SIZE[0], CAPYBARA_WINDOW_SIZE[1]
69
+ end
70
+ Capybara.default_max_wait_time = 5 # how long should capybara wait for elements to appear on the page (ajax)
71
+
72
+ # use database_cleaner to clean the database after every test with truncation, instead of using transactional fixtures
73
+ require 'database_cleaner'
74
+ DatabaseCleaner.strategy = :truncation
75
+
76
+ # default test class for webtests
77
+ class WebTest < ActionDispatch::IntegrationTest
78
+ include Capybara::DSL
79
+ extend Minitest::Spec::DSL
80
+ include Minitest::Reporters::Screenshot
81
+
82
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
83
+ fixtures :all
84
+
85
+ # disable transactional fixtures, as we use DatabaseCleaner
86
+ self.use_transactional_fixtures = false
87
+
88
+ # clean database after each test with database_cleaner
89
+ def after_teardown
90
+ super
91
+ DatabaseCleaner.clean
92
+ end
93
+ end
94
+
33
95
  <% end -%>
@@ -2,4 +2,6 @@ class ApplicationController < ActionController::Base
2
2
  # Prevent CSRF attacks by raising an exception.
3
3
  # For APIs, you may want to use :null_session instead.
4
4
  protect_from_forgery with: :exception
5
+
6
+ add_flash_types :success, :warning, :info
5
7
  end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ layout 'mailer'
3
+ default from: 'info@myapp.com'
4
+ end
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creategem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Jancev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -206,14 +206,16 @@ files:
206
206
  - templates/plugin_scaffold/test/dummy/Rakefile
207
207
  - templates/plugin_scaffold/test/dummy/app/assets/images/.keep
208
208
  - templates/plugin_scaffold/test/dummy/app/assets/javascripts/application.js
209
- - templates/plugin_scaffold/test/dummy/app/assets/stylesheets/application.css
209
+ - templates/plugin_scaffold/test/dummy/app/assets/stylesheets/application.sass
210
210
  - templates/plugin_scaffold/test/dummy/app/controllers/application_controller.rb
211
211
  - templates/plugin_scaffold/test/dummy/app/controllers/concerns/.keep
212
212
  - templates/plugin_scaffold/test/dummy/app/helpers/application_helper.rb
213
- - templates/plugin_scaffold/test/dummy/app/mailers/.keep
213
+ - templates/plugin_scaffold/test/dummy/app/mailers/application_mailer.rb
214
214
  - templates/plugin_scaffold/test/dummy/app/models/.keep
215
215
  - templates/plugin_scaffold/test/dummy/app/models/concerns/.keep
216
216
  - templates/plugin_scaffold/test/dummy/app/views/layouts/application.html.erb
217
+ - templates/plugin_scaffold/test/dummy/app/views/layouts/mailer.html.erb
218
+ - templates/plugin_scaffold/test/dummy/app/views/layouts/mailer.text.erb
217
219
  - templates/plugin_scaffold/test/dummy/bin/bundle
218
220
  - templates/plugin_scaffold/test/dummy/bin/rails
219
221
  - templates/plugin_scaffold/test/dummy/bin/rake
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */