jeweler 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semver +1 -1
- data/.travis.yml +5 -1
- data/ChangeLog.markdown +4 -0
- data/Gemfile +23 -23
- data/Gemfile.lock +142 -0
- data/Gemfile.orig +54 -0
- data/README.markdown +3 -0
- data/Rakefile +13 -14
- data/Rakefile.orig +88 -0
- data/features/generator/test.feature +2 -2
- data/features/step_definitions/debug_steps.rb +0 -1
- data/features/step_definitions/filesystem_steps.rb +2 -3
- data/features/step_definitions/generator_steps.rb +44 -64
- data/features/step_definitions/task_steps.rb +1 -2
- data/features/support/env.rb +21 -7
- data/jeweler.gemspec +11 -6
- data/jeweler.gemspec.orig +464 -0
- data/lib/jeweler.rb +18 -19
- data/lib/jeweler/commands/build_gem.rb +2 -2
- data/lib/jeweler/commands/check_dependencies.rb +3 -3
- data/lib/jeweler/commands/install_gem.rb +1 -1
- data/lib/jeweler/commands/release_gemspec.rb +8 -10
- data/lib/jeweler/commands/release_to_git.rb +9 -5
- data/lib/jeweler/commands/validate_gemspec.rb +5 -7
- data/lib/jeweler/commands/version/base.rb +8 -13
- data/lib/jeweler/commands/version/bump_major.rb +1 -3
- data/lib/jeweler/commands/version/bump_minor.rb +1 -2
- data/lib/jeweler/commands/version/bump_patch.rb +1 -4
- data/lib/jeweler/commands/write_gemspec.rb +4 -3
- data/lib/jeweler/gemspec_helper.rb +15 -15
- data/lib/jeweler/gemspec_helper.rb.orig +91 -0
- data/lib/jeweler/generator.rb +39 -41
- data/lib/jeweler/generator/application.rb +5 -7
- data/lib/jeweler/generator/bacon_mixin.rb +2 -4
- data/lib/jeweler/generator/github_mixin.rb +1 -3
- data/lib/jeweler/generator/micronaut_mixin.rb +3 -3
- data/lib/jeweler/generator/minitest_mixin.rb +2 -3
- data/lib/jeweler/generator/options.rb +15 -19
- data/lib/jeweler/generator/rdoc_mixin.rb +1 -1
- data/lib/jeweler/generator/riot_mixin.rb +2 -3
- data/lib/jeweler/generator/rspec_mixin.rb +2 -3
- data/lib/jeweler/generator/shindo_mixin.rb +2 -3
- data/lib/jeweler/generator/shoulda_mixin.rb +2 -3
- data/lib/jeweler/generator/testspec_mixin.rb +2 -3
- data/lib/jeweler/generator/testunit_mixin.rb +1 -3
- data/lib/jeweler/generator/yard_mixin.rb +3 -4
- data/lib/jeweler/rubyforge_tasks.rb +13 -13
- data/lib/jeweler/rubygems_dot_org_tasks.rb +3 -3
- data/lib/jeweler/rubygems_tasks.rb +3 -3
- data/lib/jeweler/specification.rb +22 -11
- data/lib/jeweler/tasks.rb +57 -57
- data/lib/jeweler/templates/bacon/flunking.rb +3 -3
- data/lib/jeweler/templates/micronaut/flunking.rb +3 -3
- data/lib/jeweler/templates/minitest/flunking.rb +1 -1
- data/lib/jeweler/templates/minitest/helper.rb +3 -3
- data/lib/jeweler/templates/riot/flunking.rb +1 -1
- data/lib/jeweler/templates/rspec/flunking.rb +3 -3
- data/lib/jeweler/templates/shindo/flunking.rb +3 -3
- data/lib/jeweler/templates/testspec/flunking.rb +3 -3
- data/lib/jeweler/version_helper.rb +18 -15
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -1
- data/test/fixtures/existing-project-with-version-constant/Rakefile +18 -20
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +2 -2
- data/test/jeweler/commands/test_build_gem.rb +25 -28
- data/test/jeweler/commands/test_install_gem.rb +7 -7
- data/test/jeweler/commands/test_release_to_gemcutter.rb +6 -7
- data/test/jeweler/commands/test_release_to_git.rb +52 -57
- data/test/jeweler/commands/test_release_to_github.rb +112 -119
- data/test/jeweler/commands/test_validate_gemspec.rb +4 -6
- data/test/jeweler/commands/test_write_gemspec.rb +21 -24
- data/test/jeweler/commands/version/test_base.rb +9 -10
- data/test/jeweler/commands/version/test_bump_major.rb +1 -5
- data/test/jeweler/commands/version/test_bump_minor.rb +1 -2
- data/test/jeweler/commands/version/test_bump_patch.rb +1 -3
- data/test/jeweler/commands/version/test_write.rb +1 -3
- data/test/jeweler/generator/test_application.rb +22 -26
- data/test/jeweler/generator/test_options.rb +26 -27
- data/test/jeweler/test_gemspec_helper.rb +7 -7
- data/test/jeweler/test_generator.rb +31 -32
- data/test/jeweler/test_generator_initialization.rb +40 -43
- data/test/jeweler/test_generator_mixins.rb +6 -7
- data/test/jeweler/test_specification.rb +36 -43
- data/test/jeweler/test_tasks.rb +2 -3
- data/test/jeweler/test_version_helper.rb +33 -35
- data/test/shoulda_macros/jeweler_macros.rb +5 -5
- data/test/test_helper.rb +23 -25
- data/test/test_jeweler.rb +22 -25
- metadata +11 -6
data/lib/jeweler.rb
CHANGED
@@ -16,12 +16,12 @@ class Jeweler
|
|
16
16
|
autoload :Generator, 'jeweler/generator'
|
17
17
|
|
18
18
|
autoload :Commands, 'jeweler/commands'
|
19
|
-
|
19
|
+
|
20
20
|
autoload :VersionHelper, 'jeweler/version_helper'
|
21
21
|
autoload :GemSpecHelper, 'jeweler/gemspec_helper'
|
22
22
|
|
23
23
|
autoload :Tasks, 'jeweler/tasks'
|
24
|
-
autoload :RubygemsDotOrgTasks,
|
24
|
+
autoload :RubygemsDotOrgTasks, 'jeweler/rubygems_dot_org_tasks'
|
25
25
|
autoload :GemcutterTasks, 'jeweler/gemcutter_tasks'
|
26
26
|
autoload :RubyforgeTasks, 'jeweler/rubyforge_tasks'
|
27
27
|
autoload :Specification, 'jeweler/specification'
|
@@ -72,7 +72,7 @@ class Jeweler
|
|
72
72
|
Jeweler::Commands::WriteGemspec.build_for(self).run
|
73
73
|
end
|
74
74
|
|
75
|
-
# Validates the project's gemspec from disk in an environment similar to how
|
75
|
+
# Validates the project's gemspec from disk in an environment similar to how
|
76
76
|
# GitHub would build from it. See http://gist.github.com/16215
|
77
77
|
def validate_gemspec
|
78
78
|
Jeweler::Commands::ValidateGemspec.build_for(self).run
|
@@ -96,26 +96,26 @@ class Jeweler
|
|
96
96
|
# Bumps the patch version.
|
97
97
|
#
|
98
98
|
# 1.5.1 -> 1.5.2
|
99
|
-
def bump_patch_version
|
99
|
+
def bump_patch_version
|
100
100
|
Jeweler::Commands::Version::BumpPatch.build_for(self).run
|
101
101
|
end
|
102
102
|
|
103
103
|
# Bumps the minor version.
|
104
104
|
#
|
105
105
|
# 1.5.1 -> 1.6.0
|
106
|
-
def bump_minor_version
|
106
|
+
def bump_minor_version
|
107
107
|
Jeweler::Commands::Version::BumpMinor.build_for(self).run
|
108
108
|
end
|
109
109
|
|
110
110
|
# Bumps the major version.
|
111
111
|
#
|
112
112
|
# 1.5.1 -> 2.0.0
|
113
|
-
def bump_major_version
|
113
|
+
def bump_major_version
|
114
114
|
Jeweler::Commands::Version::BumpMajor.build_for(self).run
|
115
115
|
end
|
116
116
|
|
117
117
|
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
118
|
-
def write_version(major, minor, patch, build,
|
118
|
+
def write_version(major, minor, patch, build, _options = {})
|
119
119
|
command = Jeweler::Commands::Version::Write.build_for(self)
|
120
120
|
command.major = major
|
121
121
|
command.minor = minor
|
@@ -153,26 +153,25 @@ class Jeweler
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def git_base_dir(base_dir = nil)
|
156
|
-
if base_dir
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
return nil if base_dir==File.dirname(
|
162
|
-
return base_dir if File.
|
163
|
-
|
164
|
-
end
|
156
|
+
base_dir = if base_dir
|
157
|
+
File.dirname(base_dir)
|
158
|
+
else
|
159
|
+
File.expand_path(self.base_dir || '.')
|
160
|
+
end
|
161
|
+
return nil if base_dir == File.dirname('/')
|
162
|
+
return base_dir if File.exist?(File.join(base_dir, '.git'))
|
163
|
+
git_base_dir(base_dir)
|
164
|
+
end
|
165
165
|
|
166
166
|
def in_git_repo?
|
167
167
|
git_base_dir
|
168
168
|
end
|
169
169
|
|
170
|
-
def
|
171
|
-
File.
|
170
|
+
def version_file_exist?
|
171
|
+
File.exist?(@version_helper.plaintext_path) || File.exist?(@version_helper.yaml_path)
|
172
172
|
end
|
173
173
|
|
174
174
|
def expects_version_file?
|
175
175
|
gemspec.version.nil?
|
176
176
|
end
|
177
|
-
|
178
177
|
end
|
@@ -12,10 +12,10 @@ class Jeweler
|
|
12
12
|
|
13
13
|
gemspec = gemspec_helper.parse
|
14
14
|
|
15
|
-
if Gem::Version.new(`gem -v`) >= Gem::Version.new(
|
15
|
+
if Gem::Version.new(`gem -v`) >= Gem::Version.new('2.0.0.a')
|
16
16
|
gem_file_name = Gem::Package.build(gemspec)
|
17
17
|
else
|
18
|
-
require
|
18
|
+
require 'rubygems/builder'
|
19
19
|
gem_file_name = Gem::Builder.new(gemspec).build
|
20
20
|
end
|
21
21
|
|
@@ -13,12 +13,12 @@ class Jeweler
|
|
13
13
|
if missing_dependencies.empty?
|
14
14
|
puts "#{type || 'All'} dependencies seem to be installed."
|
15
15
|
else
|
16
|
-
puts
|
16
|
+
puts 'Missing some dependencies. Install them with the following commands:'
|
17
17
|
missing_dependencies.each do |dependency|
|
18
|
-
puts %
|
18
|
+
puts %(\tgem install #{dependency.name} --version "#{dependency.requirement}")
|
19
19
|
end
|
20
20
|
|
21
|
-
abort "Run the specified gem commands before trying to run this again:
|
21
|
+
abort "Run the specified gem commands before trying to run this again: {$PROGRAM_NAME} #{ARGV.join(' ')}"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -13,7 +13,7 @@ class Jeweler
|
|
13
13
|
command = "#{gem_command} install #{gemspec_helper.gem_path}"
|
14
14
|
output.puts "Executing #{command.inspect}:"
|
15
15
|
|
16
|
-
sh command # TODO where does sh actually come from!? - rake, apparently
|
16
|
+
sh command # TODO: where does sh actually come from!? - rake, apparently
|
17
17
|
end
|
18
18
|
|
19
19
|
def gem_command
|
@@ -3,7 +3,8 @@ require 'pathname'
|
|
3
3
|
class Jeweler
|
4
4
|
module Commands
|
5
5
|
class ReleaseGemspec
|
6
|
-
attr_accessor :gemspec, :version, :repo, :output, :
|
6
|
+
attr_accessor :gemspec, :version, :repo, :output, :base_dir
|
7
|
+
attr_writer :gemspec_helper
|
7
8
|
|
8
9
|
def initialize(attributes = {})
|
9
10
|
self.output = $stdout
|
@@ -20,8 +21,8 @@ class Jeweler
|
|
20
21
|
remote_branch = args[:remote_branch] || branch
|
21
22
|
|
22
23
|
unless clean_staging_area?
|
23
|
-
system
|
24
|
-
raise
|
24
|
+
system 'git status'
|
25
|
+
raise 'Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above.'
|
25
26
|
end
|
26
27
|
|
27
28
|
repo.checkout(local_branch)
|
@@ -35,7 +36,7 @@ class Jeweler
|
|
35
36
|
|
36
37
|
def clean_staging_area?
|
37
38
|
# surprisingly simpler than ruby-git
|
38
|
-
`git ls-files --deleted --modified --others --exclude-standard` ==
|
39
|
+
`git ls-files --deleted --modified --others --exclude-standard` == ''
|
39
40
|
end
|
40
41
|
|
41
42
|
def commit_gemspec!
|
@@ -56,14 +57,11 @@ class Jeweler
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def gemspec_helper
|
59
|
-
@gemspec_helper ||= Jeweler::GemSpecHelper.new(
|
60
|
+
@gemspec_helper ||= Jeweler::GemSpecHelper.new(gemspec, base_dir)
|
60
61
|
end
|
61
62
|
|
62
63
|
def working_subdir
|
63
|
-
|
64
|
-
cwd = base_dir_path
|
65
|
-
@working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
|
66
|
-
@working_subdir
|
64
|
+
@working_subdir ||= base_dir_path.relative_path_from(Pathname.new(repo.dir.path))
|
67
65
|
end
|
68
66
|
|
69
67
|
def base_dir_path
|
@@ -71,7 +69,7 @@ class Jeweler
|
|
71
69
|
end
|
72
70
|
|
73
71
|
def self.build_for(jeweler)
|
74
|
-
command =
|
72
|
+
command = new
|
75
73
|
|
76
74
|
command.base_dir = jeweler.base_dir
|
77
75
|
command.gemspec = jeweler.gemspec
|
@@ -18,8 +18,8 @@ class Jeweler
|
|
18
18
|
remote_branch = args[:remote_branch] || branch
|
19
19
|
|
20
20
|
unless clean_staging_area?
|
21
|
-
system
|
22
|
-
raise
|
21
|
+
system 'git status'
|
22
|
+
raise 'Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above.'
|
23
23
|
end
|
24
24
|
|
25
25
|
repo.checkout(local_branch)
|
@@ -35,7 +35,7 @@ class Jeweler
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def clean_staging_area?
|
38
|
-
`git ls-files --deleted --modified --others --exclude-standard` ==
|
38
|
+
`git ls-files --deleted --modified --others --exclude-standard` == ''
|
39
39
|
end
|
40
40
|
|
41
41
|
def release_tag
|
@@ -43,12 +43,16 @@ class Jeweler
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def release_not_tagged?
|
46
|
-
tag =
|
46
|
+
tag = begin
|
47
|
+
repo.tag(release_tag)
|
48
|
+
rescue
|
49
|
+
nil
|
50
|
+
end
|
47
51
|
tag.nil?
|
48
52
|
end
|
49
53
|
|
50
54
|
def self.build_for(jeweler)
|
51
|
-
command =
|
55
|
+
command = new
|
52
56
|
|
53
57
|
command.base_dir = jeweler.base_dir
|
54
58
|
command.gemspec = jeweler.gemspec
|
@@ -8,13 +8,11 @@ class Jeweler
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
raise
|
17
|
-
end
|
11
|
+
gemspec_helper.parse
|
12
|
+
output.puts "#{gemspec_helper.path} is valid."
|
13
|
+
rescue Exception => _e
|
14
|
+
output.puts "#{gemspec_helper.path} is invalid. See the backtrace for more details."
|
15
|
+
raise
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.build_for(jeweler)
|
@@ -4,41 +4,36 @@ class Jeweler
|
|
4
4
|
module Commands
|
5
5
|
module Version
|
6
6
|
class Base
|
7
|
-
|
8
7
|
attr_accessor :repo, :version_helper, :gemspec, :commit, :base_dir
|
9
8
|
|
10
9
|
def run
|
11
10
|
update_version
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
version_helper.write
|
13
|
+
gemspec.version = version_helper.to_s
|
15
14
|
|
16
|
-
commit_version if
|
15
|
+
commit_version if repo && commit
|
17
16
|
end
|
18
17
|
|
19
18
|
def update_version
|
20
|
-
raise
|
19
|
+
raise 'Subclasses should implement this'
|
21
20
|
end
|
22
21
|
|
23
22
|
def commit_version
|
24
|
-
if
|
25
|
-
|
26
|
-
|
23
|
+
if repo
|
24
|
+
repo.add(working_subdir.join(version_helper.path).to_s)
|
25
|
+
repo.commit("Version bump to #{version_helper}")
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
def working_subdir
|
31
|
-
|
32
|
-
cwd = base_dir_path
|
33
|
-
@working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
|
34
|
-
@working_subdir
|
30
|
+
@working_subdir ||= base_dir_path.relative_path_from(Pathname.new(repo.dir.path))
|
35
31
|
end
|
36
32
|
|
37
33
|
def base_dir_path
|
38
34
|
Pathname.new(base_dir).realpath
|
39
35
|
end
|
40
36
|
|
41
|
-
|
42
37
|
def self.build_for(jeweler)
|
43
38
|
command = new
|
44
39
|
command.repo = jeweler.repo
|
@@ -1,7 +1,8 @@
|
|
1
1
|
class Jeweler
|
2
2
|
module Commands
|
3
3
|
class WriteGemspec
|
4
|
-
attr_accessor :base_dir, :gemspec, :version, :output, :
|
4
|
+
attr_accessor :base_dir, :gemspec, :version, :output, :version_helper
|
5
|
+
attr_writer :gemspec_helper
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
self.output = $stdout
|
@@ -15,11 +16,11 @@ class Jeweler
|
|
15
16
|
|
16
17
|
gemspec_helper.write
|
17
18
|
|
18
|
-
output.puts "Generated: #{gemspec_helper.path}"
|
19
|
+
output.puts "Generated: #{gemspec_helper.path}"
|
19
20
|
end
|
20
21
|
|
21
22
|
def gemspec_helper
|
22
|
-
@gemspec_helper ||= GemSpecHelper.new(
|
23
|
+
@gemspec_helper ||= GemSpecHelper.new(gemspec, base_dir)
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.build_for(jeweler)
|
@@ -10,18 +10,16 @@ class Jeweler
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def valid?
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
false
|
18
|
-
end
|
13
|
+
parse
|
14
|
+
true
|
15
|
+
rescue
|
16
|
+
false
|
19
17
|
end
|
20
18
|
|
21
19
|
def write
|
22
20
|
File.open(path, 'w') do |f|
|
23
|
-
f.write
|
24
|
-
end
|
21
|
+
f.write to_ruby
|
22
|
+
end
|
25
23
|
end
|
26
24
|
|
27
25
|
def to_ruby
|
@@ -42,13 +40,15 @@ class Jeweler
|
|
42
40
|
def path
|
43
41
|
denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec")
|
44
42
|
absolute_path = File.expand_path(denormalized_path)
|
45
|
-
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
43
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
46
44
|
end
|
47
45
|
|
46
|
+
PARSE_SAFE = (RUBY_VERSION >= '2.3') ? 1 : 3
|
47
|
+
|
48
48
|
def parse
|
49
|
-
data =
|
49
|
+
data = to_ruby
|
50
50
|
parsed_gemspec = nil
|
51
|
-
Thread.new { parsed_gemspec = eval("$SAFE =
|
51
|
+
Thread.new { parsed_gemspec = eval("$SAFE = #{PARSE_SAFE}\n#{data}", binding, path) }.join
|
52
52
|
parsed_gemspec
|
53
53
|
end
|
54
54
|
|
@@ -65,9 +65,9 @@ class Jeweler
|
|
65
65
|
# Adds extra space when outputting an array. This helps create better version control diffs, because otherwise it is all on the same line.
|
66
66
|
def prettyify_array(gemspec_ruby, array_name)
|
67
67
|
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
68
|
-
leadin, files = match[0..-2].split(
|
69
|
-
|
70
|
-
leadin + "[\n #{files.gsub(
|
68
|
+
leadin, files = match[0..-2].split('[')
|
69
|
+
|
70
|
+
leadin + "[\n #{files.gsub(%(", "), %(",\n "))}\n ]"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -78,7 +78,7 @@ class Jeweler
|
|
78
78
|
def update_version(version)
|
79
79
|
@spec.version = version.to_s
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
# Checks whether it uses the version helper or the users defined version.
|
83
83
|
def has_version?
|
84
84
|
!@spec.version.nil?
|
@@ -0,0 +1,91 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class GemSpecHelper
|
3
|
+
attr_accessor :spec, :base_dir
|
4
|
+
|
5
|
+
def initialize(spec, base_dir = nil)
|
6
|
+
self.spec = spec
|
7
|
+
self.base_dir = base_dir || ''
|
8
|
+
|
9
|
+
yield spec if block_given?
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid?
|
13
|
+
parse
|
14
|
+
true
|
15
|
+
rescue
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def write
|
20
|
+
File.open(path, 'w') do |f|
|
21
|
+
f.write to_ruby
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_ruby
|
26
|
+
normalize_files(:files)
|
27
|
+
normalize_files(:extra_rdoc_files)
|
28
|
+
|
29
|
+
gemspec_ruby = @spec.to_ruby
|
30
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :files)
|
31
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
|
32
|
+
gemspec_ruby = <<-END
|
33
|
+
# Generated by jeweler
|
34
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
35
|
+
# Instead, edit Jeweler::Tasks in #{Rake.application.rakefile}, and run 'rake gemspec'
|
36
|
+
#{gemspec_ruby}
|
37
|
+
END
|
38
|
+
end
|
39
|
+
|
40
|
+
def path
|
41
|
+
denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec")
|
42
|
+
absolute_path = File.expand_path(denormalized_path)
|
43
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
44
|
+
end
|
45
|
+
|
46
|
+
PARSE_SAFE = (RUBY_VERSION >= '2.3') ? 1 : 3
|
47
|
+
|
48
|
+
def parse
|
49
|
+
data = to_ruby
|
50
|
+
parsed_gemspec = nil
|
51
|
+
<<<<<<< HEAD
|
52
|
+
Thread.new { parsed_gemspec = eval("$SAFE = 1\n#{data}", binding, path) }.join
|
53
|
+
=======
|
54
|
+
Thread.new { parsed_gemspec = eval("$SAFE = #{PARSE_SAFE}\n#{data}", binding, path) }.join
|
55
|
+
>>>>>>> 1d6f8d13d012c584ad37b496c999edfb0127aadc
|
56
|
+
parsed_gemspec
|
57
|
+
end
|
58
|
+
|
59
|
+
def normalize_files(array_attribute)
|
60
|
+
array = @spec.send(array_attribute)
|
61
|
+
# only keep files, no directories, and sort
|
62
|
+
array = array.select do |path|
|
63
|
+
File.file? File.join(@base_dir, path)
|
64
|
+
end.sort
|
65
|
+
|
66
|
+
@spec.send("#{array_attribute}=", array)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Adds extra space when outputting an array. This helps create better version control diffs, because otherwise it is all on the same line.
|
70
|
+
def prettyify_array(gemspec_ruby, array_name)
|
71
|
+
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
72
|
+
leadin, files = match[0..-2].split('[')
|
73
|
+
|
74
|
+
leadin + "[\n #{files.gsub(%(", "), %(",\n "))}\n ]"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def gem_path
|
79
|
+
File.join(@base_dir, 'pkg', parse.file_name)
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_version(version)
|
83
|
+
@spec.version = version.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks whether it uses the version helper or the users defined version.
|
87
|
+
def has_version?
|
88
|
+
!@spec.version.nil?
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|