permutation-tools 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d590e6fed36c7595c8397844ab89eadca25a2ab
4
- data.tar.gz: 95f191de60e371e78ca7452c0cab8f29652f417d
3
+ metadata.gz: e8333c3a9db115f5e4b980e5c6c8eee9d0d57ace
4
+ data.tar.gz: bb9d9007ad703f2bbdb743b9187879133cc8ce52
5
5
  SHA512:
6
- metadata.gz: 3279d4a2e589e1cc7af23913c3b1ed01a186699dcf2d3ff89cdd3c4e5aca4edd8aa180870a5ae161df6e0d7546f094f0d67a565b5ffaa131d3eba7d5ddcaac74
7
- data.tar.gz: b53d792d8fb41c62f2337d933e28e88816a4e27328647f9cee33d94167ec89c171adb6890575edbfcebd291b88ca25ef030b24a4b02b11afa0b0268ed413b3c2
6
+ metadata.gz: ca2af212bc9489b365dc21558d99a3d0137271a2d08d4046a94e32b19e52087b3de6697d9301adc9f6835be7cbfbf006a04563dae46f4ad3a4f17580f53e9157
7
+ data.tar.gz: 3ca20b7846f092dc048560ea854d481f6c1813c81477ad660ddff846716375bfc96ecf8f3a34aad157d024d5bc4edac54253fff046b63fc506b57a160a811ac4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.3
data/lib/ext/hash.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Hash
2
+ def slice(*keys)
3
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
4
+ keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
5
+ end
6
+ end
@@ -3,6 +3,7 @@ require 'faraday'
3
3
  require 'open-uri'
4
4
  require 'nokogiri'
5
5
 
6
+ require_relative 'ext/hash'
6
7
  require_relative 'ext/scraper'
7
8
 
8
9
  require_relative 'tools/api'
data/lib/tools/api.rb CHANGED
@@ -40,7 +40,7 @@ module Permutation
40
40
 
41
41
  def host
42
42
  @host = ENV['HOST'] ||
43
- Permutation::Config.account['host'] ||
43
+ Permutation::Config.host ||
44
44
  DEFAULT_HOST
45
45
  end
46
46
  end
data/lib/tools/config.rb CHANGED
@@ -5,48 +5,40 @@ module Permutation
5
5
  REPOSITORY_CONFIG_FILE = File.join(Dir.pwd, '.permutation')
6
6
 
7
7
  def account
8
- Permutation::Config.read(ACCOUNT_CONFIG_FILE) || begin
9
- access_token = nil
10
- json = {}
8
+ Permutation::Config.read(ACCOUNT_CONFIG_FILE) || init
9
+ end
10
+
11
+ def init
12
+ access_token = nil
13
+ json = {}
14
+
15
+ puts "Log In to Permutation"
16
+ email = ask("Email: ")
17
+ password = ask("Password: ") {|q| q.echo = false}
11
18
 
12
- puts "Log In to Permutation"
13
- email = ask("Email: ")
14
- password = ask("Password: ") {|q| q.echo = false}
19
+ response = Permutation::API.post '/api/session.json', { email: email, password: password }
15
20
 
16
- response = Permutation::API.post '/api/session.json', { email: email, password: password }
17
- if response.status == 201
18
- session = response.body.select{|k,_| ["email","access_token"].include? k}
19
- json.merge! session
20
- json.merge! host: Permutation::API.host unless Permutation::API.host == Permutation::API::DEFAULT_HOST
21
+ if response.status == 201
22
+ session = response.body.slice("email","access_token")
23
+ json.merge! session
24
+ json.merge! host: Permutation::API.host unless Permutation::API.host == Permutation::API::DEFAULT_HOST
21
25
 
22
- write(json, ACCOUNT_CONFIG_FILE)
23
- json
24
- else
25
- puts
26
- puts "Invalid login credentials"
27
- exit
28
- end
26
+ write(json, ACCOUNT_CONFIG_FILE)
27
+ json
28
+ else
29
+ puts
30
+ puts "Invalid login credentials"
31
+ exit
29
32
  end
30
33
  end
31
34
 
32
- # def repository
33
- # regex = /git@github\.com|git@bitbucket\.org:(.*)\.git/
34
- # Permutation::Config.read(REPOSITORY_CONFIG_FILE) || begin
35
- # json = {}
36
- # account_config = account
37
- # `git remote show origin | grep Fetch | cut -d: -f2-`.match(regex)
38
- # repo_name = $1
39
- #
40
- # repos = Permutation::API.get('/api/repositories.json', 'Access-Token' => account_config['access_token']).body
41
- # if repo = repos['repositories'].detect{|repo| repo['name'] == repo_name}
42
- # json.merge! 'repo' => repo['name']
43
- # write(json, REPOSITORY_CONFIG_FILE)
44
- # json
45
- # else
46
- # puts "Unable to find repo #{repo_name}"
47
- # end
48
- # end
49
- # end
35
+ def host
36
+ if config = Permutation::Config.read(ACCOUNT_CONFIG_FILE)
37
+ config['host']
38
+ else
39
+ nil
40
+ end
41
+ end
50
42
  end
51
43
 
52
44
 
data/lib/tools/release.rb CHANGED
@@ -8,21 +8,26 @@ module Permutation
8
8
  sha = `git rev-parse #{remote_branch}`
9
9
 
10
10
  regex = /(git@github\.com|git@bitbucket\.org):(.*)\.git/
11
- `git remote show origin | grep Fetch | cut -d: -f2-`.match(regex)
11
+ repo_url = `git remote show origin | grep Fetch | cut -d: -f2-`.strip
12
+ repo_url.match(regex)
12
13
  repo_name = $2
13
14
 
14
15
  response = Permutation::API.post(
15
16
  '/api/releases.json',
16
17
  options.merge({
17
18
  sha: sha,
19
+ repo_url: repo_url,
18
20
  repo_name: repo_name
19
21
  }),
20
22
  { 'Access-Token' => account_config['access_token'] }
21
23
  )
22
24
 
23
25
  if response.status == 201
24
- response.body["releases"].each do |release|
25
- puts "Created release #{release['version']} for #{release['account']['name']}"
26
+ release = response.body
27
+ if options[:force]
28
+ puts "Updated release #{release['version']} for #{release['repository']['name']}"
29
+ else
30
+ puts "Created release #{release['version']} for #{release['repository']['name']}"
26
31
  end
27
32
  elsif response.status == 401
28
33
  puts "Unauthorized, please re-run permutation init"
@@ -31,7 +36,11 @@ module Permutation
31
36
  puts "Repository #{repo_name} not found"
32
37
  exit
33
38
  else
34
- puts "Error"
39
+ if error = response.body
40
+ puts "Error: #{error['message']}"
41
+ else
42
+ puts "Error"
43
+ end
35
44
  end
36
45
  end
37
46
 
@@ -50,6 +59,10 @@ module Permutation
50
59
  # options[:parent] = v
51
60
  # end
52
61
 
62
+ opts.on("-f", "--force [VERSION]", "Iterate using the new release") do |v|
63
+ options[:force] = v
64
+ end
65
+
53
66
  opts.on("-i", "--iterate [ITERATE]", "Iterate using the new release") do |v|
54
67
  options[:iterate] = v
55
68
  end
@@ -2,40 +2,47 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: permutation-tools 0.1.0 ruby lib
5
+ # stub: permutation-tools 0.2.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "permutation-toolbelt"
9
- s.version = "0.2.1"
8
+ s.name = "permutation-tools"
9
+ s.version = "0.2.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Ian Hunter"]
14
- s.date = "2014-11-03"
14
+ s.date = "2015-08-24"
15
15
  s.description = ""
16
- s.email = "ian@permutation.io"
16
+ s.email = "ianhunter@gmail.com"
17
17
  s.executables = ["permutation"]
18
18
  s.extra_rdoc_files = [
19
19
  "LICENSE.txt",
20
- "README.rdoc"
20
+ "README.md"
21
21
  ]
22
22
  s.files = [
23
- ".document",
24
23
  "Gemfile",
25
24
  "Gemfile.lock",
26
25
  "LICENSE.txt",
27
- "README.rdoc",
26
+ "README.md",
28
27
  "Rakefile",
29
28
  "VERSION",
30
29
  "bin/permutation",
30
+ "index.html",
31
+ "lib/ext/hash.rb",
32
+ "lib/ext/scraper.rb",
31
33
  "lib/permutation-tools.rb",
34
+ "lib/tools/api.rb",
35
+ "lib/tools/config.rb",
36
+ "lib/tools/mirror.rb",
37
+ "lib/tools/release.rb",
38
+ "lib/tools/server.rb",
32
39
  "permutation-tools.gemspec",
33
40
  "test/helper.rb",
34
41
  "test/test_permutation-tools.rb"
35
42
  ]
36
- s.homepage = "http://github.com/permutation.io/toolbelt"
43
+ s.homepage = "http://github.com/ihunter/permutation-tools"
37
44
  s.licenses = ["MIT"]
38
- s.rubygems_version = "2.2.2"
45
+ s.rubygems_version = "2.4.6"
39
46
  s.summary = "Tools for working with Permutation"
40
47
 
41
48
  if s.respond_to? :specification_version then
@@ -46,6 +53,8 @@ Gem::Specification.new do |s|
46
53
  s.add_runtime_dependency(%q<highline>, [">= 0"])
47
54
  s.add_runtime_dependency(%q<json>, [">= 0"])
48
55
  s.add_runtime_dependency(%q<semantic>, [">= 0"])
56
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
57
+ s.add_development_dependency(%q<byebug>, [">= 0"])
49
58
  s.add_development_dependency(%q<shoulda>, [">= 0"])
50
59
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
51
60
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
@@ -56,6 +65,8 @@ Gem::Specification.new do |s|
56
65
  s.add_dependency(%q<highline>, [">= 0"])
57
66
  s.add_dependency(%q<json>, [">= 0"])
58
67
  s.add_dependency(%q<semantic>, [">= 0"])
68
+ s.add_dependency(%q<sinatra>, [">= 0"])
69
+ s.add_dependency(%q<byebug>, [">= 0"])
59
70
  s.add_dependency(%q<shoulda>, [">= 0"])
60
71
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
72
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -67,6 +78,8 @@ Gem::Specification.new do |s|
67
78
  s.add_dependency(%q<highline>, [">= 0"])
68
79
  s.add_dependency(%q<json>, [">= 0"])
69
80
  s.add_dependency(%q<semantic>, [">= 0"])
81
+ s.add_dependency(%q<sinatra>, [">= 0"])
82
+ s.add_dependency(%q<byebug>, [">= 0"])
70
83
  s.add_dependency(%q<shoulda>, [">= 0"])
71
84
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
72
85
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -74,3 +87,4 @@ Gem::Specification.new do |s|
74
87
  s.add_dependency(%q<simplecov>, [">= 0"])
75
88
  end
76
89
  end
90
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permutation-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Hunter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -181,6 +181,7 @@ files:
181
181
  - VERSION
182
182
  - bin/permutation
183
183
  - index.html
184
+ - lib/ext/hash.rb
184
185
  - lib/ext/scraper.rb
185
186
  - lib/permutation-tools.rb
186
187
  - lib/tools/api.rb