gem-beit 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5464cb24526597c1636204d92f4356f334d80d84
4
+ data.tar.gz: a1710d9a6b6920a28a69efc6cba13ce8e3262ccb
5
+ SHA512:
6
+ metadata.gz: 49ccc35be1ef380c2fb9bbac11103f04e26b56dc73c5be3c426af6dde35fd8eb8dc850fd09aaf7aabaa4a6bf92c901b043e555bdb6b19b69616897dc56c3b76f
7
+ data.tar.gz: 065cab2e1a853489d529097fafb2e6ad39006ad68b73465a56006191d941b61b82f9fbf83f22170b8c84a8952abf3409f9a585f919531658f2291adb9db9f80c
@@ -0,0 +1 @@
1
+ /pkg/
@@ -0,0 +1,3 @@
1
+ [submodule "task"]
2
+ path = task
3
+ url = git://github.com/godfat/gemgem.git
@@ -0,0 +1,9 @@
1
+ before_install: 'git submodule update --init'
2
+ script: 'ruby -r bundler/setup -S rake test'
3
+
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - ruby
8
+ - rbx
9
+ - jruby
@@ -0,0 +1,5 @@
1
+ # CHANGES
2
+
3
+ ## gem-beit 0.6.0 -- 2014-10-27
4
+
5
+ * Birthday!
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,62 @@
1
+ # gem-beit [![Build Status](https://secure.travis-ci.org/godfat/gem-beit.png?branch=master)](http://travis-ci.org/godfat/gem-beit)
2
+
3
+ by Lin Jen-Shin ([godfat](http://godfat.org))
4
+
5
+ ## LINKS:
6
+
7
+ * [github](https://github.com/godfat/gem-beit)
8
+ * [rubygems](https://rubygems.org/gems/gem-beit)
9
+
10
+ ## DESCRIPTION:
11
+
12
+ Edit a gem for a given name from Gemfile.
13
+
14
+ Also checkout [gem-eit][].
15
+
16
+ [gem-eit]: https://github.com/godfat/gem-eit
17
+
18
+ ## REQUIREMENTS:
19
+
20
+ * Tested with MRI (official CRuby), Rubinius and JRuby.
21
+ * [gem-path](https://github.com/godfat/gem-path)
22
+ * vim from shell, or set $GEM_EDITOR or $EDITOR to the editor you want.
23
+
24
+ ## INSTALLATION:
25
+
26
+ gem install gem-beit
27
+
28
+ ## SYNOPSIS:
29
+
30
+ Please set either $GEM_EDITOR or $EDITOR to the editor you want.
31
+ By default it would pick vim if nothing is set.
32
+
33
+ Also checkout [gem.fish][] for [fish][] completion.
34
+
35
+ [gem.fish]: https://github.com/godfat/dev-tool/blob/master/.config/fish/completions/gem.fish
36
+ [fish]: http://fishshell.com/
37
+
38
+ ### Edit gem
39
+
40
+ gem beit rib # $EDITOR ~/.gem/ruby/2.0.0/gems/rib-1.0.0
41
+
42
+ ## CONTRIBUTORS:
43
+
44
+ * Lin Jen-Shin (@godfat)
45
+
46
+ ## LICENSE:
47
+
48
+ Apache License 2.0
49
+
50
+ Copyright (c) 2014, Lin Jen-Shin (godfat)
51
+
52
+ Licensed under the Apache License, Version 2.0 (the "License");
53
+ you may not use this file except in compliance with the License.
54
+ You may obtain a copy of the License at
55
+
56
+ <http://www.apache.org/licenses/LICENSE-2.0>
57
+
58
+ Unless required by applicable law or agreed to in writing, software
59
+ distributed under the License is distributed on an "AS IS" BASIS,
60
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ See the License for the specific language governing permissions and
62
+ limitations under the License.
@@ -0,0 +1,14 @@
1
+
2
+ begin
3
+ require "#{dir = File.dirname(__FILE__)}/task/gemgem"
4
+ rescue LoadError
5
+ sh 'git submodule update --init'
6
+ exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
7
+ end
8
+
9
+ Gemgem.init(dir) do |s|
10
+ s.name = 'gem-beit'
11
+ s.version = '0.6.0'
12
+ s.add_runtime_dependency('gem-path', '>= 0.6.0')
13
+ s.add_runtime_dependency('bundler')
14
+ end
@@ -0,0 +1,46 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # stub: gem-beit 0.6.0 ruby lib
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "gem-beit"
6
+ s.version = "0.6.0"
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib"]
10
+ s.authors = ["Lin Jen-Shin (godfat)"]
11
+ s.date = "2014-10-27"
12
+ s.description = "Edit a gem for a given name from Gemfile.\n\nAlso checkout [gem-eit][].\n\n[gem-eit]: https://github.com/godfat/gem-eit"
13
+ s.email = ["godfat (XD) godfat.org"]
14
+ s.files = [
15
+ ".gitignore",
16
+ ".gitmodules",
17
+ ".travis.yml",
18
+ "CHANGES.md",
19
+ "LICENSE",
20
+ "README.md",
21
+ "Rakefile",
22
+ "gem-beit.gemspec",
23
+ "lib/rubygems/commands/beit_command.rb",
24
+ "lib/rubygems_plugin.rb",
25
+ "task/README.md",
26
+ "task/gemgem.rb"]
27
+ s.homepage = "https://github.com/godfat/gem-beit"
28
+ s.licenses = ["Apache License 2.0"]
29
+ s.rubygems_version = "2.4.2"
30
+ s.summary = "Edit a gem for a given name from Gemfile."
31
+
32
+ if s.respond_to? :specification_version then
33
+ s.specification_version = 4
34
+
35
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
36
+ s.add_runtime_dependency(%q<gem-path>, [">= 0.6.0"])
37
+ s.add_runtime_dependency(%q<bundler>, [">= 0"])
38
+ else
39
+ s.add_dependency(%q<gem-path>, [">= 0.6.0"])
40
+ s.add_dependency(%q<bundler>, [">= 0"])
41
+ end
42
+ else
43
+ s.add_dependency(%q<gem-path>, [">= 0.6.0"])
44
+ s.add_dependency(%q<bundler>, [">= 0"])
45
+ end
46
+ end
@@ -0,0 +1,47 @@
1
+
2
+ class Gem::Commands::BeitCommand < Gem::Command
3
+ def description
4
+ 'Edit from current Gemfile'
5
+ end
6
+
7
+ def initialize
8
+ super('beit', description)
9
+ end
10
+
11
+ def execute
12
+ require 'rubygems/commands/path_command'
13
+ require 'bundler/setup'
14
+
15
+ if options[:args].first.nil?
16
+ say("Usage: gem beit [GEM NAME]")
17
+ elsif Bundler::SharedHelpers.in_bundle?
18
+ beit
19
+ else
20
+ say("No Gemfile detected.")
21
+ end
22
+ end
23
+
24
+ def beit
25
+ cmd = Gem::Commands::PathCommand.new
26
+ name = options[:args].first
27
+ spec = Bundler.locked_gems.specs.find do |s|
28
+ name == s.name
29
+ end
30
+
31
+ if spec
32
+ gem(spec.name, spec.version)
33
+ exec("#{eit} #{cmd.find_gem_path(spec.name)}")
34
+ else
35
+ say("#{name} not found.")
36
+ end
37
+ end
38
+
39
+ def exec *args
40
+ say(args.join(' '))
41
+ super
42
+ end
43
+
44
+ def eit
45
+ ENV['GEM_EDITOR'] || ENV['EDITOR'] || 'vim'
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+
2
+ require 'rubygems/command_manager'
3
+ Gem::CommandManager.instance.register_command(:beit)
@@ -0,0 +1,54 @@
1
+ # Gemgem
2
+
3
+ ## DESCRIPTION:
4
+
5
+ Provided tasks:
6
+
7
+ rake clean # Remove ignored files
8
+ rake gem:build # Build gem
9
+ rake gem:install # Install gem
10
+ rake gem:release # Release gem
11
+ rake gem:spec # Generate gemspec
12
+ rake test # Run tests in memory
13
+
14
+ ## REQUIREMENTS:
15
+
16
+ * Tested with MRI (official CRuby) 1.9.3, 2.0.0, Rubinius and JRuby.
17
+
18
+ ## INSTALLATION:
19
+
20
+ git submodule add git://github.com/godfat/gemgem.git task
21
+
22
+ And in Rakefile:
23
+
24
+ ``` ruby
25
+ begin
26
+ require "#{dir = File.dirname(__FILE__)}/task/gemgem"
27
+ rescue LoadError
28
+ sh 'git submodule update --init'
29
+ exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
30
+ end
31
+
32
+ Gemgem.init(dir) do |s|
33
+ s.name = 'your-gem'
34
+ s.version = '0.1.0'
35
+ end
36
+ ```
37
+
38
+ ## LICENSE:
39
+
40
+ Apache License 2.0
41
+
42
+ Copyright (c) 2011-2013, Lin Jen-Shin (godfat)
43
+
44
+ Licensed under the Apache License, Version 2.0 (the "License");
45
+ you may not use this file except in compliance with the License.
46
+ You may obtain a copy of the License at
47
+
48
+ <http://www.apache.org/licenses/LICENSE-2.0>
49
+
50
+ Unless required by applicable law or agreed to in writing, software
51
+ distributed under the License is distributed on an "AS IS" BASIS,
52
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ See the License for the specific language governing permissions and
54
+ limitations under the License.
@@ -0,0 +1,258 @@
1
+
2
+ module Gemgem
3
+ class << self
4
+ attr_accessor :dir, :spec, :spec_create
5
+ end
6
+
7
+ module_function
8
+ def gem_tag ; "#{spec.name}-#{spec.version}" ; end
9
+ def gem_path ; "#{pkg_dir}/#{gem_tag}.gem" ; end
10
+ def spec_path ; "#{dir}/#{spec.name}.gemspec" ; end
11
+ def pkg_dir ; "#{dir}/pkg" ; end
12
+ def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
13
+
14
+ def init dir, &block
15
+ self.dir = dir
16
+ $LOAD_PATH.unshift("#{dir}/lib")
17
+ ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
18
+ ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
19
+ self.spec_create = block
20
+ end
21
+
22
+ def create
23
+ spec = Gem::Specification.new do |s|
24
+ s.authors = ['Lin Jen-Shin (godfat)']
25
+ s.email = ['godfat (XD) godfat.org']
26
+
27
+ s.description = description.join
28
+ s.summary = description.first
29
+ s.license = readme['LICENSE'].sub(/.+\n\n/, '').lines.first.strip
30
+
31
+ s.date = Time.now.strftime('%Y-%m-%d')
32
+ s.files = gem_files
33
+ s.test_files = test_files
34
+ s.executables = bin_files
35
+ end
36
+ spec_create.call(spec)
37
+ spec.homepage ||= "https://github.com/godfat/#{spec.name}"
38
+ self.spec = spec
39
+ end
40
+
41
+ def write
42
+ File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
43
+ end
44
+
45
+ def split_lines ruby
46
+ ruby.gsub(/(.+?)\s*=\s*\[(.+?)\]/){ |s|
47
+ if $2.index(',')
48
+ "#{$1} = [\n #{$2.split(',').map(&:strip).join(",\n ")}]"
49
+ else
50
+ s
51
+ end
52
+ }
53
+ end
54
+
55
+ def strip_path path
56
+ strip_home_path(strip_cwd_path(path))
57
+ end
58
+
59
+ def strip_home_path path
60
+ path.sub(ENV['HOME'], '~')
61
+ end
62
+
63
+ def strip_cwd_path path
64
+ path.sub(Dir.pwd, '.')
65
+ end
66
+
67
+ def git *args
68
+ `git --git-dir=#{dir}/.git #{args.join(' ')}`
69
+ end
70
+
71
+ def sh_git *args
72
+ Rake.sh('git', "--git-dir=#{dir}/.git", *args)
73
+ end
74
+
75
+ def sh_gem *args
76
+ Rake.sh(Gem.ruby, '-S', 'gem', *args)
77
+ end
78
+
79
+ def glob path=dir
80
+ Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
81
+ end
82
+
83
+ def readme
84
+ @readme ||=
85
+ if (path = "#{Gemgem.dir}/README.md") && File.exist?(path)
86
+ ps = "##{File.read(path)}".
87
+ scan(/((#+)[^\n]+\n\n.+?(?=(\n\n\2[^#\n]+\n)|\Z))/m).map(&:first)
88
+ ps.inject('HEADER' => ps.first){ |r, s, i|
89
+ r[s[/\w+/]] = s
90
+ r
91
+ }
92
+ else
93
+ {}
94
+ end
95
+ end
96
+
97
+ def description
98
+ # JRuby String#lines is returning an enumerator
99
+ @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
100
+ end
101
+
102
+ def all_files
103
+ @all_files ||= fold_files(glob).sort
104
+ end
105
+
106
+ def fold_files files
107
+ files.inject([]){ |r, path|
108
+ if File.file?(path) && path !~ %r{/\.git(/|$)} &&
109
+ (rpath = path[%r{^#{escaped_dir}/(.*$)}, 1])
110
+ r << rpath
111
+ elsif File.symlink?(path) # walk into symlinks...
112
+ r.concat(fold_files(glob(File.expand_path(path,
113
+ File.readlink(path)))))
114
+ else
115
+ r
116
+ end
117
+ }
118
+ end
119
+
120
+ def gem_files
121
+ @gem_files ||= all_files.reject{ |f|
122
+ f =~ ignored_pattern && !git_files.include?(f)
123
+ }
124
+ end
125
+
126
+ def test_files
127
+ @test_files ||= gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
128
+ end
129
+
130
+ def bin_files
131
+ @bin_files ||= gem_files.grep(%r{^bin/}).map{ |f| File.basename(f) }
132
+ end
133
+
134
+ def git_files
135
+ @git_files ||= if File.exist?("#{dir}/.git")
136
+ git('ls-files').split("\n")
137
+ else
138
+ []
139
+ end
140
+ end
141
+
142
+ def ignored_files
143
+ @ignored_files ||= all_files.grep(ignored_pattern)
144
+ end
145
+
146
+ def ignored_pattern
147
+ @ignored_pattern ||= if gitignore.empty?
148
+ /^$/
149
+ else
150
+ Regexp.new(expand_patterns(gitignore).join('|'))
151
+ end
152
+ end
153
+
154
+ def expand_patterns pathes
155
+ # http://git-scm.com/docs/gitignore
156
+ pathes.flat_map{ |path|
157
+ # we didn't implement negative pattern for now
158
+ Regexp.escape(path).sub(%r{^/}, '^').gsub(/\\\*/, '[^/]*')
159
+ }
160
+ end
161
+
162
+ def gitignore
163
+ @gitignore ||= if File.exist?(path = "#{dir}/.gitignore")
164
+ File.read(path).lines.
165
+ reject{ |l| l == /^\s*(#|\s+$)/ }.map(&:strip)
166
+ else
167
+ []
168
+ end
169
+ end
170
+ end
171
+
172
+ namespace :gem do
173
+
174
+ desc 'Install gem'
175
+ task :install => [:build] do
176
+ Gemgem.sh_gem('install', Gemgem.gem_path)
177
+ end
178
+
179
+ desc 'Build gem'
180
+ task :build => [:spec] do
181
+ require 'fileutils'
182
+ require 'rubygems/package'
183
+ gem = nil
184
+ Dir.chdir(Gemgem.dir) do
185
+ gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
186
+ FileUtils.mkdir_p(Gemgem.pkg_dir)
187
+ FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
188
+ end
189
+ puts "\e[35mGem built: \e[33m" \
190
+ "#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
191
+ end
192
+
193
+ desc 'Generate gemspec'
194
+ task :spec do
195
+ Gemgem.create
196
+ Gemgem.write
197
+ end
198
+
199
+ desc 'Release gem'
200
+ task :release => [:spec, :check, :build] do
201
+ Gemgem.module_eval do
202
+ sh_git('tag', Gemgem.gem_tag)
203
+ sh_git('push')
204
+ sh_git('push', '--tags')
205
+ sh_gem('push', Gemgem.gem_path)
206
+ end
207
+ end
208
+
209
+ task :check do
210
+ ver = Gemgem.spec.version.to_s
211
+
212
+ if ENV['VERSION'].nil?
213
+ puts("\e[35mExpected " \
214
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
215
+ exit(1)
216
+
217
+ elsif ENV['VERSION'] != ver
218
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
219
+ "\e[35mbut got\n " \
220
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
221
+ exit(2)
222
+ end
223
+ end
224
+
225
+ end # of gem namespace
226
+
227
+ desc 'Run tests'
228
+ task :test do
229
+ next if Gemgem.test_files.empty?
230
+ Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
231
+ end
232
+
233
+ desc 'Trash ignored files'
234
+ task :clean => ['gem:spec'] do
235
+ next if Gemgem.ignored_files.empty?
236
+
237
+ require 'fileutils'
238
+ trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
239
+ puts "Move the following files into:" \
240
+ " \e[35m#{Gemgem.strip_path(trash)}\e[33m"
241
+
242
+ Gemgem.ignored_files.each do |file|
243
+ from = "#{Gemgem.dir}/#{file}"
244
+ to = "#{trash}/#{File.dirname(file)}"
245
+ puts Gemgem.strip_path(from)
246
+
247
+ FileUtils.mkdir_p(to)
248
+ FileUtils.mv(from, to)
249
+ end
250
+
251
+ print "\e[0m"
252
+ end
253
+
254
+ task :default do
255
+ # Is there a reliable way to do this in the current process?
256
+ # It failed miserably before between Rake versions...
257
+ exec "#{Gem.ruby} -S #{$PROGRAM_NAME} -f #{Rake.application.rakefile} -T"
258
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-beit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Lin Jen-Shin (godfat)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem-path
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.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.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
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
+ description: |-
42
+ Edit a gem for a given name from Gemfile.
43
+
44
+ Also checkout [gem-eit][].
45
+
46
+ [gem-eit]: https://github.com/godfat/gem-eit
47
+ email:
48
+ - godfat (XD) godfat.org
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ".gitignore"
54
+ - ".gitmodules"
55
+ - ".travis.yml"
56
+ - CHANGES.md
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - gem-beit.gemspec
61
+ - lib/rubygems/commands/beit_command.rb
62
+ - lib/rubygems_plugin.rb
63
+ - task/README.md
64
+ - task/gemgem.rb
65
+ homepage: https://github.com/godfat/gem-beit
66
+ licenses:
67
+ - Apache License 2.0
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.4.2
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Edit a gem for a given name from Gemfile.
89
+ test_files: []