gembank_client 0.0.2

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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p0
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source('http://rubygems.org')
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kostiantyn Kahanskyi
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,32 @@
1
+ # GemBank-Client is a command line utility for managing Gems on http://gembank.org
2
+
3
+
4
+ ## Installation
5
+
6
+ With Bundler:
7
+
8
+ ```ruby
9
+ gem 'gembank_client' # Gemfile
10
+ ```
11
+
12
+ Old-Style:
13
+
14
+ ```bash
15
+ $ gem install gembank_client
16
+ ```
17
+
18
+
19
+
20
+ ## Usage
21
+
22
+ ### Creating / Updating Gems
23
+
24
+ ```bash
25
+ $ gembank_client release -k c93a3fcd6720bf27b53801d8d7fbc7fa7747df60 -f superman-1.2.3.gem
26
+ ```
27
+
28
+ * The SHA1 is the Push-Key allowed to write to GemBucket `superman`. See http://gembank.org/how-does-it-work for details.
29
+ * The file is the Gem you want to create / update.
30
+
31
+ ### Yanking Gems will follow ASAP.
32
+
data/README.txt ADDED
@@ -0,0 +1 @@
1
+ CL Client for gembank.org
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ task(:default => :spec)
data/bin/gb-cli ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gembank_client'
4
+
5
+ GembankClient::CLI.run
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gembank_client'
4
+
5
+ GembankClient::CLI.run
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/gembank_client/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'gembank_client'
5
+ gem.version = GembankClient::VERSION
6
+ gem.description = File.read(File.expand_path('../README.txt', __FILE__))
7
+ gem.summary = %q{CL Client for gembank.org}
8
+ gem.homepage = 'https://github.com/kostia/gembank_client'
9
+ gem.authors = ['Kostiantyn Kahanskyi']
10
+ gem.email = %w[info@gembank.org]
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.require_paths = %w[lib]
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
14
+ gem.add_dependency('choice')
15
+ gem.add_dependency('rest-client')
16
+ gem.add_development_dependency('pry')
17
+ gem.add_development_dependency('rake')
18
+ gem.add_development_dependency('rspec')
19
+ end
@@ -0,0 +1,50 @@
1
+ require 'choice'
2
+ require 'gembank_client/resource'
3
+ require 'singleton'
4
+
5
+ module GembankClient
6
+ class CLI
7
+ include Singleton
8
+
9
+ def self.run
10
+ instance.run
11
+ end
12
+
13
+ def run
14
+ Choice.options do
15
+ banner('Usage: gembank_client ACTION --key=KEY --file=GEM_FILE [--url=URL]')
16
+ header('Available actions: release')
17
+ header('Options:')
18
+ option(:key, :required => true) do
19
+ short('-k')
20
+ long('--key=KEY')
21
+ desc('Push key (required)')
22
+ end
23
+ option(:file, :required => true) do
24
+ short('-f')
25
+ long('--file=FILE')
26
+ desc('Gem file (required)')
27
+ end
28
+ option(:url) do
29
+ short('-u')
30
+ long('--url=URL')
31
+ desc('Gembank URL')
32
+ end
33
+ end
34
+
35
+ action = ARGV.first
36
+ puts(Choice.help) unless action
37
+
38
+ resource = GembankClient::Resource.new(Choice.choices[:key], Choice.choices[:file],
39
+ Choice.choices[:url])
40
+
41
+ case action
42
+ when 'release'
43
+ resource.release
44
+ else
45
+ puts("Unknown action '#{action}'\n")
46
+ puts(Choice.help)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,36 @@
1
+ require 'rest_client'
2
+
3
+ module GembankClient
4
+ class Resource
5
+ DEFAULT_URL = 'https://gembank.org'
6
+
7
+ def initialize(key, file, url = DEFAULT_URL)
8
+ @key, @file, @url = key, file, url
9
+ end
10
+
11
+ def release
12
+ RestClient.post(url, :gem => File.new(@file)) do |response, request, result, &block|
13
+ handle(response, request, result, &block)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def url
20
+ "#{@url}/push/#{@key}"
21
+ end
22
+
23
+ def handle(response, request, result, &block)
24
+ case response.code
25
+ when 200, 202
26
+ puts(response.body)
27
+ when 403, 404, 412
28
+ puts("Server responded with status code #{response.code}")
29
+ puts(response.body) if response.body and response.body.size > 0
30
+ exit response.code
31
+ else
32
+ response.return!(request, result, &block)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module GembankClient
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'gembank_client/cli'
2
+
3
+ module GembankClient
4
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe GembankClient::Resource do
4
+ it 'should have a default URL specified' do
5
+ GembankClient::Resource::DEFAULT_URL.should == 'https://gembank.org'
6
+ end
7
+
8
+ describe 'when releasing a gem' do
9
+ let(:resource) { GembankClient::Resource.new('foobar123', 'spec/fixtures/gems/some.gem') }
10
+
11
+ it 'should post to push URL with gem file' do
12
+ RestClient.should_receive(:post) do |url, options|
13
+ url.should == 'https://gembank.org/push/foobar123'
14
+ options[:gem].path.should == 'spec/fixtures/gems/some.gem'
15
+ end
16
+ resource.release
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ require 'rake'
2
+
3
+ include Rake::DSL
4
+
5
+ FileList['lib/**/*.rb'].each { |f| load f }
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gembank_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kostiantyn Kahanskyi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: choice
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! 'CL Client for gembank.org
95
+
96
+ '
97
+ email:
98
+ - info@gembank.org
99
+ executables:
100
+ - gb-cli
101
+ - gembank_client
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rbenv-version
107
+ - .rspec
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - README.txt
112
+ - Rakefile
113
+ - bin/gb-cli
114
+ - bin/gembank_client
115
+ - gembank_client.gemspec
116
+ - lib/gembank_client.rb
117
+ - lib/gembank_client/cli.rb
118
+ - lib/gembank_client/resource.rb
119
+ - lib/gembank_client/version.rb
120
+ - spec/gembank_client/resource_spec.rb
121
+ - spec/spec_helper.rb
122
+ homepage: https://github.com/kostia/gembank_client
123
+ licenses: []
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 1.8.23
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: CL Client for gembank.org
146
+ test_files: []