parka 0.7.0 → 0.7.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.
- data/README.md +87 -0
- data/data/example/lib/somegem.rb +3 -0
- data/data/example/somegem.gemspec +12 -0
- data/lib/parka.rb +4 -0
- data/lib/parka/cli.rb +117 -0
- data/lib/parka/specification.rb +60 -0
- data/lib/rubygems_plugin.rb +0 -0
- data/spec/parka/cli_spec.rb +2 -0
- data/spec/parka/specification_spec.rb +28 -0
- data/spec/parka_spec.rb +8 -0
- data/spec/spec_helper.rb +6 -0
- metadata +22 -11
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# parka
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
$ gem install parka
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Create a `projectname.gemspec` file in the root of your gem like this:
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
require "parka/specification"
|
13
|
+
|
14
|
+
Parka::Specification.new do |gem|
|
15
|
+
gem.name = "somegem"
|
16
|
+
gem.version = Somegem::VERSION
|
17
|
+
gem.summary = "A sample gem"
|
18
|
+
gem.homepage = "http://example.org"
|
19
|
+
end
|
20
|
+
|
21
|
+
Create a `Gemfile` to declare the dependencies of your gem:
|
22
|
+
|
23
|
+
source "http://rubygems.org"
|
24
|
+
|
25
|
+
gem "rest-client"
|
26
|
+
|
27
|
+
group :development do
|
28
|
+
gem "parka"
|
29
|
+
end
|
30
|
+
|
31
|
+
group :test do
|
32
|
+
gem "rake"
|
33
|
+
gem "rcov"
|
34
|
+
gem "rspec"
|
35
|
+
end
|
36
|
+
|
37
|
+
Gems in the `development` and `test` groups will become development
|
38
|
+
dependencies of your gem.
|
39
|
+
|
40
|
+
## Building Gems
|
41
|
+
|
42
|
+
The gem can be built by using `gem build projectname.gemspec`
|
43
|
+
|
44
|
+
## Using the parka command-line tool
|
45
|
+
|
46
|
+
### parka build
|
47
|
+
|
48
|
+
Build a .gem file.
|
49
|
+
|
50
|
+
$ parka build
|
51
|
+
Building somegem-0.1.gem
|
52
|
+
Successfully built RubyGem
|
53
|
+
Name: somegem
|
54
|
+
Version: 0.1
|
55
|
+
File: somegem-0.1.gem
|
56
|
+
|
57
|
+
### parka install
|
58
|
+
|
59
|
+
Build a .gem file and install it locally.
|
60
|
+
|
61
|
+
$ parka install
|
62
|
+
Building somegem-0.1.gem
|
63
|
+
Successfully built RubyGem
|
64
|
+
Name: somegem
|
65
|
+
Version: 0.1
|
66
|
+
File: somegem-0.1.gem
|
67
|
+
Successfully installed somegem-0.1.gem
|
68
|
+
|
69
|
+
### parka push
|
70
|
+
|
71
|
+
Build a .gem file and push it to Github and RubyGems.org. Will create the GitHub repo if necessary.
|
72
|
+
|
73
|
+
$ parka push
|
74
|
+
Building somegem-0.1.gem
|
75
|
+
Successfully built RubyGem
|
76
|
+
Name: somegem
|
77
|
+
Version: 0.1
|
78
|
+
File: somegem-0.1.gem
|
79
|
+
Delta compression using up to 8 threads.
|
80
|
+
Compressing objects: 100% (8/8), done.
|
81
|
+
Writing objects: 100% (9/9), 1.26 KiB, done.
|
82
|
+
Total 9 (delta 3), reused 0 (delta 0)
|
83
|
+
To git@github.com:ddollar/somegem.git
|
84
|
+
edffa40..249581c master -> master
|
85
|
+
* [new tag] v0.1 -> v0.1
|
86
|
+
Pushing gem to RubyGems.org...
|
87
|
+
Successfully registered gem: somegem (0.1)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# this is only necessary to build from trunk rather than a release
|
2
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "parka/specification"
|
6
|
+
|
7
|
+
Parka::Specification.new do |gem|
|
8
|
+
gem.name = "somegem"
|
9
|
+
gem.version = Somegem::VERSION
|
10
|
+
gem.summary = "A sample gem"
|
11
|
+
gem.homepage = "http://example.org"
|
12
|
+
end
|
data/lib/parka.rb
ADDED
data/lib/parka/cli.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
require "crack"
|
2
|
+
require "rubygems/commands/push_command"
|
3
|
+
require "rubygems/dependency_installer"
|
4
|
+
require "parka"
|
5
|
+
require "psych"
|
6
|
+
require "rest_client"
|
7
|
+
require "thor"
|
8
|
+
|
9
|
+
class Parka::CLI < Thor
|
10
|
+
|
11
|
+
desc "build [GEMSPEC]", "Build the gem"
|
12
|
+
|
13
|
+
method_option :filename, :type => :string, :aliases => "-f",
|
14
|
+
:desc => "Build to the specified filename"
|
15
|
+
|
16
|
+
def build(gemspec_filename=nil)
|
17
|
+
gemspec = Gem::Specification.load(gemspec_filename || default_gemspec)
|
18
|
+
filename = options[:filename] || "pkg/#{gemspec.file_name}"
|
19
|
+
|
20
|
+
say "Building #{gemspec.file_name}"
|
21
|
+
|
22
|
+
FileUtils.mkdir_p File.dirname(filename)
|
23
|
+
Gem::Builder.new(gemspec).build
|
24
|
+
FileUtils.mv gemspec.file_name, filename
|
25
|
+
|
26
|
+
filename
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "install [GEMSPEC]", "Build and install the gem"
|
30
|
+
|
31
|
+
def install(gemspec_filename=nil)
|
32
|
+
original_home = ENV["GEM_HOME"]
|
33
|
+
gemfile = build(gemspec_filename)
|
34
|
+
ENV["GEM_HOME"] = original_home
|
35
|
+
|
36
|
+
system "gem install #{gemfile}"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "push [GEMSPEC]", "Build the gem and push it to GitHub and RubyGems.org"
|
40
|
+
|
41
|
+
method_option :create, :type => :boolean, :aliases => "-c",
|
42
|
+
:desc => "Create a Github repository for this project"
|
43
|
+
|
44
|
+
method_option :filename, :type => :string, :aliases => "-f",
|
45
|
+
:desc => "Build to the specified filename"
|
46
|
+
|
47
|
+
def push(gemspec_filename=nil)
|
48
|
+
gemspec = Gem::Specification.load(gemspec_filename || default_gemspec)
|
49
|
+
gemfile = options[:filename] || build(gemspec_filename)
|
50
|
+
|
51
|
+
# create github remote
|
52
|
+
remotes = %x{ git remote }.strip.split("\n")
|
53
|
+
unless remotes.include?("github")
|
54
|
+
%x{ git remote add github git@github.com:#{github_username}/#{gemspec.name}.git }
|
55
|
+
end
|
56
|
+
|
57
|
+
# create github repo
|
58
|
+
if options[:create]
|
59
|
+
begin
|
60
|
+
github["repos/create"].post(
|
61
|
+
:name => gemspec.name,
|
62
|
+
:description => gemspec.summary,
|
63
|
+
:homepage => gemspec.homepage,
|
64
|
+
:public => "1"
|
65
|
+
)
|
66
|
+
rescue
|
67
|
+
error "Unable to create GitHub repository: #{gemspec.name}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# create release tag
|
72
|
+
%x{ git tag v#{gemspec.version} }
|
73
|
+
|
74
|
+
# push to github
|
75
|
+
%x{ git push github master --tags }
|
76
|
+
|
77
|
+
# push to rubygems
|
78
|
+
pusher = Gem::Commands::PushCommand.new
|
79
|
+
pusher.send_gem gemfile
|
80
|
+
end
|
81
|
+
|
82
|
+
private ######################################################################
|
83
|
+
|
84
|
+
def chroot(dir)
|
85
|
+
FileUtils.mkdir_p dir
|
86
|
+
|
87
|
+
Dir.chdir(dir) { yield }
|
88
|
+
end
|
89
|
+
|
90
|
+
def default_gemspec
|
91
|
+
"#{File.basename(Dir.pwd)}.gemspec"
|
92
|
+
end
|
93
|
+
|
94
|
+
def error(message)
|
95
|
+
puts "ERROR: #{message}"
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
|
99
|
+
def github
|
100
|
+
username = github_username + "/token"
|
101
|
+
password = github_token
|
102
|
+
RestClient::Resource.new("http://github.com/api/v2/json", username, password)
|
103
|
+
end
|
104
|
+
|
105
|
+
def github_username
|
106
|
+
%x{ git config github.user }.strip
|
107
|
+
end
|
108
|
+
|
109
|
+
def github_token
|
110
|
+
%x{ git config github.token }.strip
|
111
|
+
end
|
112
|
+
|
113
|
+
def github_repositories
|
114
|
+
Crack::JSON.parse(github["repos/show/#{github_username}"].get)["repositories"]
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "parka"
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
class Parka::Specification < Gem::Specification
|
6
|
+
|
7
|
+
def self.new(&block)
|
8
|
+
gemspec_filename = caller.first.split(':').first
|
9
|
+
|
10
|
+
# add the lib/ dir of the gem to the load path
|
11
|
+
$:.unshift File.expand_path(File.join(File.dirname(gemspec_filename), 'lib'))
|
12
|
+
|
13
|
+
# autorequire the same name as the gem spec
|
14
|
+
require File.basename(gemspec_filename, File.extname(gemspec_filename))
|
15
|
+
|
16
|
+
spec = Gem::Specification.new(&block)
|
17
|
+
|
18
|
+
# set up some sensible defaults
|
19
|
+
spec.author ||= default_author
|
20
|
+
spec.email ||= default_email
|
21
|
+
spec.description ||= spec.summary
|
22
|
+
|
23
|
+
# hack to avoid rubyforge_project warning
|
24
|
+
spec.rubyforge_project = "nowarning"
|
25
|
+
|
26
|
+
# default file list if none specified
|
27
|
+
spec.files = (spec.files + default_files).uniq
|
28
|
+
|
29
|
+
# get dependencies from bundler
|
30
|
+
add_bundler_dependencies(spec)
|
31
|
+
|
32
|
+
spec
|
33
|
+
end
|
34
|
+
|
35
|
+
private ######################################################################
|
36
|
+
|
37
|
+
def self.default_author
|
38
|
+
%x{ git config user.name }
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.default_email
|
42
|
+
%x{ git config user.email }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.default_files
|
46
|
+
%x{ git ls-files }.split("\n").select { |f| f.match(%r{^(README|bin/|data/|ext/|lib/|spec/|test/)}) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.add_bundler_dependencies(spec)
|
50
|
+
groups = Bundler.definition.groups - [:development, :test]
|
51
|
+
deps = Bundler.definition.dependencies
|
52
|
+
|
53
|
+
runtime = deps.select { |d| (d.groups & groups).any? }
|
54
|
+
development = deps - runtime
|
55
|
+
|
56
|
+
development.each { |d| spec.add_development_dependency(d.name, *d.requirement.as_list) }
|
57
|
+
runtime.each { |d| spec.add_dependency(d.name, *d.requirement.as_list) }
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "parka/specification"
|
3
|
+
|
4
|
+
describe Parka::Specification do
|
5
|
+
|
6
|
+
describe "initializer" do
|
7
|
+
let(:spec) { Parka::Specification.new }
|
8
|
+
|
9
|
+
it "sets defaults" do
|
10
|
+
mock($:).unshift(File.expand_path("../../parka/lib", __FILE__))
|
11
|
+
|
12
|
+
mock(Parka::Specification).require("specification_spec")
|
13
|
+
mock(Parka::Specification).default_author.returns("default_author")
|
14
|
+
mock(Parka::Specification).default_email.returns("default_email")
|
15
|
+
mock(Parka::Specification).add_bundler_dependencies.with_any_args
|
16
|
+
|
17
|
+
any_instance_of(Gem::Specification) do |spec|
|
18
|
+
stub(spec).summary.returns("default_description")
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.author.should == "default_author"
|
22
|
+
spec.email.should == "default_email"
|
23
|
+
spec.description.should == "default_description"
|
24
|
+
spec.rubyforge_project == "nowarning"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/parka_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: crack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70259580301040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70259580301040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: psych
|
27
|
-
requirement: &
|
27
|
+
requirement: &70259580300220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70259580300220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rest-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &70259580299200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.7
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70259580299200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: thor
|
49
|
-
requirement: &
|
49
|
+
requirement: &70259580298060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.14.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70259580298060
|
58
58
|
description:
|
59
59
|
email: ddollar@gmail.com
|
60
60
|
executables:
|
@@ -63,6 +63,17 @@ extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
65
|
- bin/parka
|
66
|
+
- data/example/lib/somegem.rb
|
67
|
+
- data/example/somegem.gemspec
|
68
|
+
- lib/parka/cli.rb
|
69
|
+
- lib/parka/specification.rb
|
70
|
+
- lib/parka.rb
|
71
|
+
- lib/rubygems_plugin.rb
|
72
|
+
- README.md
|
73
|
+
- spec/parka/cli_spec.rb
|
74
|
+
- spec/parka/specification_spec.rb
|
75
|
+
- spec/parka_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
66
77
|
homepage: http://github.com/ddollar/parka
|
67
78
|
licenses: []
|
68
79
|
post_install_message:
|
@@ -77,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
88
|
version: '0'
|
78
89
|
segments:
|
79
90
|
- 0
|
80
|
-
hash:
|
91
|
+
hash: 1912434054982538250
|
81
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
93
|
none: false
|
83
94
|
requirements:
|
@@ -86,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
97
|
version: '0'
|
87
98
|
segments:
|
88
99
|
- 0
|
89
|
-
hash:
|
100
|
+
hash: 1912434054982538250
|
90
101
|
requirements: []
|
91
102
|
rubyforge_project:
|
92
103
|
rubygems_version: 1.8.10
|