gem_polish 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08d511ff59f61a52d0659a211c8631480a549fdf
4
+ data.tar.gz: 3bf795407d78b9595ec17839c5cb4feb582e3216
5
+ SHA512:
6
+ metadata.gz: 79bbce144eba9068f2bb8ee46a4791e41dd785e920aa730891bf9f6f797c4c120bf154a0aa583364c7f41f82ec40437c766e81c8ff61d1c5b843e3b1e2c08f05
7
+ data.tar.gz: 0e88b20d4232fb3ef73571cfbc30471fe49b7e1929c4e347f10817a46cea3443733a4d9af0b3b7d87a2a11b42a30f8d89b2e7e74d112e2fa5111f857d94a0f1c
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gem_polish.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 LFDM
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,52 @@
1
+ # GemPolish
2
+
3
+ Further polishes your Bundler gem skeleton.
4
+
5
+ ## Installation
6
+
7
+ $ gem install gem_polish
8
+
9
+ ## Usage
10
+
11
+ Provides two executables to improve your Bundler gem skeleton.
12
+
13
+ - polish_gem
14
+
15
+ Is meant to be used inside the directory a newly created gem (`bundle gem GEM_NAME`)
16
+ Available options:
17
+
18
+ | Option | Alias | Result |
19
+ |:---------------- |:-----:| ------ |
20
+ | `--description` | `-d` | Takes a string and writes it to the gemspec and the README |
21
+ | `--rspec_conf` | `-r` | Adds additional rspec configuration, check `lib/templates` |
22
+ | `--travis` | `-t` | Takes several ruby versions travis will use |
23
+ | `--coverage` | `-c` | Adds coveralls to your gem |
24
+ | `--badges` | `-b` | Adds badge fury, gemnasium, travis, coveralls and code climate and/or badges to your README |
25
+ | `--git_user` | `-g` | Git user name used to link to your badges. Defaults to the information inside of your `.gitconfig` |
26
+ | `--no_default` | `-n` | Disables all default values provided in your `.gem_polish.yml` file |
27
+
28
+ Unless `--no_default` is set, `polish_gem` will look into your home
29
+ directory for a `.gem_polish.yml` file, that can provide default values
30
+ for gem polishing. Check the `examples` folder for its formatting.
31
+
32
+ * create_gem
33
+
34
+ Combines gem creation and polishing:
35
+ ```
36
+ create_gem my_new_gem
37
+ ```
38
+ This will create the new gem `my_new_gem`. Arguments can be passed to
39
+ override defaults or provide a description.
40
+ ```
41
+ create_gem my_new_gem -d 'Does nothing so far'
42
+ ```
43
+ At the moment he `bundle gem` command is invoked with `-t rspec` to
44
+ provide the `rspec` test framework by default.
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( http://github.com/<my-github-username>/gem_polish/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
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/create_gem ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'yaml'
3
+
4
+ name = ARGV.shift
5
+ # bundler_options are currently not used, maybe later
6
+ #conf_file = "#{ENV['HOME']}/.gem_polish.yml"
7
+ #conf = File.exists?(conf_file) ?
8
+ #YAML.load(File.read(conf_file))['bundler_options'].to_s : {}
9
+
10
+ # hardcoding rspec as testframework
11
+ conf = '-t rspec'
12
+
13
+ b_command = "bundle gem #{name} #{conf}"
14
+ p_command = "polish_gem #{name} #{ARGV.join(' ')}"
15
+ g_command = "cd #{name} && git add -A"
16
+
17
+ exec([b_command, p_command, g_command].join (' && '))
18
+
data/bin/polish_gem ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'gem_polish'
6
+ GemPolish::CLI.start([:polish] + ARGV)
@@ -0,0 +1,15 @@
1
+ coverage: true
2
+ rspec_conf: true
3
+ badges:
4
+ - badge_fury
5
+ - gemnasium
6
+ - travis
7
+ - coveralls
8
+ - code_climate
9
+ travis:
10
+ before_script:
11
+ - "export JRUBY_OPTS=--2.0"
12
+ rvm:
13
+ - 2.1.0
14
+ - 2.0.0
15
+ - jruby-1.7.8
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gem_polish/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gem_polish"
8
+ spec.version = GemPolish::VERSION
9
+ spec.authors = ["LFDM"]
10
+ spec.email = ["1986gh@gmail.com"]
11
+ spec.summary = %q{Further polishes your bundler gem skeleton}
12
+ spec.description = %q{Adds code coverage tools, badges in README, more ruby versions in travis etc.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_dependency "thor"
25
+ end
data/gem_polish.thor ADDED
@@ -0,0 +1 @@
1
+ require 'gem_polish'
@@ -0,0 +1,144 @@
1
+ require 'thor'
2
+ require 'yaml'
3
+
4
+ module GemPolish
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ desc "polish", "polishes your gem"
9
+ method_option :badges, type: :array, aliases: '-b'
10
+ method_option :git_user, type: :string, aliases: '-g'
11
+ method_option :description, aliases: '-d'
12
+ method_option :coverage, aliases: '-c'
13
+ method_option :rspec_conf, aliases: '-r'
14
+ method_option :travis, type: :array, aliases: '-t'
15
+ method_option :no_default, aliases: '-n'
16
+ def polish(name = '.')
17
+ inside name do
18
+ default = options.has_key?('no_default') ? {} : def_conf
19
+
20
+ description = options[:description]
21
+ git_user_name = extract_git_user(options)
22
+ badges = parse_opt(:badges, options, default)
23
+ travis_opts = parse_opt(:travis, options, default)
24
+
25
+ insert_badges(badges, git_user_name, gem_name) if badges
26
+ insert_description(description) if description
27
+ insert_coveralls if parse_opt(:coverage, options, default)
28
+ insert_rspec_conf if parse_opt(:rspec_conf, options, default)
29
+ insert_travis(travis_opts) if travis_opts
30
+ end
31
+ end
32
+
33
+ no_commands do
34
+ def parse_opt(opt, opts, default)
35
+ opts[opt] || default[opt]
36
+ end
37
+
38
+ def extract_git_user(options)
39
+ user = options[:git_user] || `git config user.name`.chomp
40
+ user.empty? ? "TODO: Write your name" : user
41
+ end
42
+
43
+ def insert_description(description)
44
+ gsub_file(gemspec, /TODO:.*summary.*(?=})/, description)
45
+ gsub_file(readme, /TODO:.*gem description/, description)
46
+ end
47
+
48
+ BADGE_NAMES = {
49
+ 'badge_fury' => 'Version',
50
+ 'gemnasium' => 'Dependencies',
51
+ 'travis' => 'Build Status',
52
+ 'coveralls' => 'Coverage',
53
+ 'code_climate' => 'Code Climate'
54
+ }
55
+
56
+ def insert_badges(badges, user, gem)
57
+ insert_into_file(readme, after: /^#\s.*\n/, force: false) do
58
+ "\n#{badges.map { |badge| badge_link(badge, user, gem) }.join("\n")}\n"
59
+ end
60
+ end
61
+
62
+ def badge_link(badge, user, gem)
63
+ path = "http://allthebadges.io/#{user}/#{gem}/#{badge}"
64
+ "[![#{BADGE_NAMES[badge]}](#{path}.png)](#{path})"
65
+ end
66
+
67
+ def insert_coveralls
68
+ prepend_file(spec_helper, read_template(:coveralls) + "\n")
69
+ add_dev_dependency('simplecov', '0.7')
70
+ append_file(gemfile, %{gem 'coveralls', require: false})
71
+ end
72
+
73
+ def insert_rspec_conf
74
+ append_file(spec_helper, "\n" + read_template(:rspec_configuration))
75
+ end
76
+
77
+ def insert_travis(opts)
78
+ say_status :rewrite, relative_destination(travis)
79
+ File.write(travis, YAML.dump(travis_content(opts)))
80
+ end
81
+
82
+ def travis_content(opts)
83
+ c = { 'language' => 'ruby'}
84
+ c.merge((opts.is_a?(Hash) ? opts : { 'rvm' => opts }))
85
+ end
86
+
87
+ def relative_destination(dest)
88
+ d = File.expand_path(dest, destination_root)
89
+ relative_to_original_destination_root(d)
90
+ end
91
+
92
+ def def_conf
93
+ conf_file = "#{ENV['HOME']}/.gem_polish.yml"
94
+ conf = File.exists?(conf_file) ? YAML.load(File.read(conf_file)) : {}
95
+ conf.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
96
+ end
97
+
98
+ def gem_name
99
+ File.basename(Dir.pwd)
100
+ end
101
+
102
+ def travis
103
+ ".travis.yml"
104
+ end
105
+
106
+ def spec_helper
107
+ "spec/spec_helper.rb"
108
+ end
109
+
110
+ def gemspec
111
+ "#{gem_name}.gemspec"
112
+ end
113
+
114
+ def gemfile
115
+ "Gemfile"
116
+ end
117
+
118
+ def readme
119
+ "README.md"
120
+ end
121
+
122
+ TEMPLATE_DIR = File.expand_path('../../templates', __FILE__)
123
+ def read_template(name)
124
+ File.read("#{TEMPLATE_DIR}/#{name}.template")
125
+ end
126
+
127
+ def add_dev_dependency(gem, version = nil)
128
+ total_size = File.size(gemspec)
129
+ pos_before_end = total_size - 4
130
+ insertion = %{ spec.add_development_dependency "#{gem}"}
131
+ return if File.read(gemspec).match(/#{insertion}/)
132
+ insertion << %{, "~> #{version}"} if version
133
+
134
+ say_status :append, relative_destination(gemspec)
135
+ File.open(gemspec, 'r+') do |file|
136
+ file.seek(pos_before_end, IO::SEEK_SET)
137
+ file.puts(insertion)
138
+ file.puts('end')
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+
@@ -0,0 +1,3 @@
1
+ module GemPolish
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gem_polish.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "gem_polish/version"
2
+ require "gem_polish/cli"
@@ -0,0 +1,13 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ Coveralls.wear!
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+
11
+ SimpleCov.start do
12
+ add_filter '/spec/'
13
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.treat_symbols_as_metadata_keys_with_true_values = true
3
+ config.run_all_when_everything_filtered = true
4
+ config.filter_run :focus
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe GemPolish do
4
+ it 'should have a version number' do
5
+ GemPolish::VERSION.should_not be_nil
6
+ end
7
+
8
+ it 'should do something useful' do
9
+ false.should be_true
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'gem_polish'
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_polish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - LFDM
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-23 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Adds code coverage tools, badges in README, more ruby versions in travis
70
+ etc.
71
+ email:
72
+ - 1986gh@gmail.com
73
+ executables:
74
+ - create_gem
75
+ - polish_gem
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - .gitignore
80
+ - .rspec
81
+ - .travis.yml
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/create_gem
87
+ - bin/polish_gem
88
+ - examples/.gem_polish.yml
89
+ - gem_polish.gemspec
90
+ - gem_polish.thor
91
+ - lib/gem_polish.rb
92
+ - lib/gem_polish/cli.rb
93
+ - lib/gem_polish/version.rb
94
+ - lib/templates/coveralls.template
95
+ - lib/templates/rspec_configuration.template
96
+ - spec/gem_polish_spec.rb
97
+ - spec/spec_helper.rb
98
+ homepage: ''
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.0.3
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Further polishes your bundler gem skeleton
122
+ test_files:
123
+ - spec/gem_polish_spec.rb
124
+ - spec/spec_helper.rb