get_to_work 0.1.0 → 0.1.1

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: 2171fbf400cb9e56bbfb43830503c678088c497f
4
- data.tar.gz: 08ac477394a7859ad4603384a126535e8acdc1a1
3
+ metadata.gz: 702f1cb0f80c92a0fc96a1351a93f11dd3799c29
4
+ data.tar.gz: 95a4703aca307d23da758be2bd0cd9331e3235ff
5
5
  SHA512:
6
- metadata.gz: 7062a8c5ba2f2df16f452e89b41094b8d7b9e9b006f250933a91e08eabeffda86a62f451b53379507fcecbb4843e4c7bbaffe6916573906393f1d608d08d8375
7
- data.tar.gz: 5c7eb3898f321dd48402cd8c9f8db7ce05499789caa2da83f657b53b7c685b0a14529080fae4d6c01154ce05f8fe4d1c505ab8cd953b5da052089b102c5ee461
6
+ metadata.gz: c981e1db8108d16500160e45620b31804137f9ca155b9c71f12c2d7c1576929a24fcf3b1e626158f5203baf283b8d061d2188ee4896a452f4fd6801bb2dc219c
7
+ data.tar.gz: 6564d6a0e3aefbfd7a1ff48136b4ff5bb246448b103da5257060aceb47af09a5b44a0c89ec9a1749b8a963d206df9905d077d1d26ecd29038fd407aa78da4aac
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
@@ -2,13 +2,11 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "get_to_work"
5
+ require "pry"
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
8
9
 
9
10
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
11
+ require "pry"
12
+ Pry.start
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "rubygems"
3
+ $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
4
+
4
5
  require "get_to_work"
5
6
 
6
7
  GetToWork::CLI.start(ARGV)
@@ -21,20 +21,16 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_dependency "thor"
24
- spec.add_dependency "crack", "~> 0.4"
25
- spec.add_dependency "httparty", "~> 0.13"
26
- spec.add_dependency "addressable", "~> 2.3"
27
- spec.add_dependency "multipart-post", "~> 2.0"
28
- spec.add_dependency "rest-client", '~> 1.8'
29
- spec.add_dependency "ruby-keychain"
30
- spec.add_dependency "pivotal-tracker"
31
- spec.add_dependency "harvested"
32
- spec.add_dependency "tracker_api", "~> 0.2"
33
- spec.add_dependency "faraday", "~> 0.9"
24
+ spec.add_dependency "nokogiri", "~> 1.6", ">= 1.6.7.2"
25
+ spec.add_dependency "ruby-keychain", "~> 0.3.2"
26
+ spec.add_dependency "harvested", "~> 3.1", ">= 3.1.1"
27
+ spec.add_dependency "tracker_api", "~> 0.2.12"
34
28
 
35
29
  spec.add_development_dependency "bundler", "~> 1.10"
36
30
  spec.add_development_dependency "rake", "~> 10.0"
37
31
  spec.add_development_dependency "rspec"
38
32
  spec.add_development_dependency "pry"
39
33
  spec.add_development_dependency "rubocop"
34
+ spec.add_development_dependency "bump"
35
+ spec.add_development_dependency "guard-rspec"
40
36
  end
@@ -0,0 +1,9 @@
1
+ class String
2
+ def underscore
3
+ self.gsub(/::/, '/').
4
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
+ tr("-", "_").
7
+ downcase
8
+ end
9
+ end
@@ -1,5 +1,6 @@
1
1
  require "pry"
2
2
  require "thor"
3
+ require "ext/string"
3
4
  require "get_to_work/menu" # thor extensions
4
5
  require "get_to_work/menu_presenter"
5
6
 
@@ -1,5 +1,3 @@
1
- require "pivotal-tracker"
2
-
3
1
  module GetToWork
4
2
  class Command
5
3
  class Bootstrap < GetToWork::Command
@@ -80,7 +78,7 @@ module GetToWork
80
78
 
81
79
  begin
82
80
  service.authenticate(username: username, password: password, subdomain: subdomain)
83
- rescue RestClient::Unauthorized
81
+ rescue Service::UnauthorizedError
84
82
  @cli.say "Could not authenticate with #{service.display_name}", :red
85
83
  exit(1)
86
84
  end
@@ -1,17 +1,22 @@
1
1
  module GetToWork
2
2
  class Service
3
+ class UnauthorizedError < StandardError
4
+ end
5
+
3
6
  attr_reader :api_token
4
7
 
5
8
  class << self
6
- attr_accessor :yaml_key, :name, :display_name
9
+ def display_name(name = nil)
10
+ @display_name = name || @display_name
11
+ end
7
12
  end
8
13
 
9
14
  def yaml_key
10
- self.class.yaml_key
15
+ name.underscore
11
16
  end
12
17
 
13
18
  def name
14
- self.class.name
19
+ self.class.to_s.split("::").last
15
20
  end
16
21
 
17
22
  def display_name
@@ -22,8 +27,12 @@ module GetToWork
22
27
  return if data_hash.nil?
23
28
 
24
29
  @data = data_hash[yaml_key]
30
+
25
31
  if @data
26
- @data.each { |name, value| instance_variable_set("@#{name}", value) }
32
+ @data.each do |name, value|
33
+ instance_variable_set("@#{name}", value)
34
+ self.class.class_eval { attr_reader(name.to_sym) }
35
+ end
27
36
  authenticate_with_keychain
28
37
  end
29
38
  end
@@ -33,12 +42,15 @@ module GetToWork
33
42
  raise "@name not set for #{name}" if @api_token.nil?
34
43
 
35
44
  GetToWork::Keychain.new.update(
36
- service: self.class.name,
45
+ service: name,
37
46
  account: account,
38
47
  password: @api_token
39
48
  )
40
49
  end
41
50
 
51
+ def authenticate_with_keychain
52
+ end
53
+
42
54
  def api_token
43
55
  if keychain && @api_token.nil?
44
56
  @api_token = keychain.password
@@ -3,9 +3,7 @@ require "harvested"
3
3
  module GetToWork
4
4
  class Service
5
5
  class Harvest < GetToWork::Service
6
- @yaml_key = "harvest"
7
- @name = "Harvest"
8
- @display_name = "Harvest"
6
+ display_name "Harvest"
9
7
 
10
8
  attr_reader :subdomain, :project_id, :task_id
11
9
  def initialize(yaml_hash)
@@ -1,16 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tracker_api"
4
+ require "nokogiri"
4
5
 
5
6
  module GetToWork
6
7
  class Service
7
8
  class PivotalTracker < GetToWork::Service
8
- @yaml_key = "pivotal_tracker"
9
- @name = "PivotalTracker"
10
- @display_name = "Pivotal Tracker"
9
+ display_name "Pivotal Tracker"
11
10
 
12
- def authenticate(username:, password:, subdomain:_)
13
- @api_token = ::PivotalTracker::Client.token(username, password)
11
+ def get_auth_token(user:, pass:)
12
+ # POST
13
+ uri = URI("https://www.pivotaltracker.com/services/v3/tokens/active")
14
+ req = Net::HTTP::Get.new(uri)
15
+ req.basic_auth user, pass
16
+
17
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
18
+ http.request(req)
19
+ end
20
+
21
+ case res
22
+ when Net::HTTPUnauthorized
23
+ raise Service::UnauthorizedError
24
+ else
25
+ res
26
+ end
27
+
28
+ # Parse the token
29
+ xml = Nokogiri::XML(res.body)
30
+ xml.xpath("//guid").first.text
31
+ end
32
+
33
+ def authenticate(username:, password:, subdomain:)
34
+ token = get_auth_token(user: username, pass: password)
35
+ set_client_token(token)
14
36
  end
15
37
 
16
38
  def authenticate_with_keychain
@@ -28,7 +50,7 @@ module GetToWork
28
50
  end
29
51
 
30
52
  def api_client
31
- @api_client ||= TrackerApi::Client.new(token: @api_token)
53
+ @api_client ||= TrackerApi::Client.new(token: api_token)
32
54
  end
33
55
 
34
56
  def projects
@@ -1,3 +1,3 @@
1
1
  module GetToWork
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_to_work
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Rittersdorf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -25,97 +25,109 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: crack
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '1.6'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.6.7.2
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '0.4'
43
+ version: '1.6'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.6.7.2
41
47
  - !ruby/object:Gem::Dependency
42
- name: httparty
48
+ name: ruby-keychain
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0.13'
53
+ version: 0.3.2
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0.13'
60
+ version: 0.3.2
55
61
  - !ruby/object:Gem::Dependency
56
- name: addressable
62
+ name: harvested
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '2.3'
67
+ version: '3.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.1.1
62
71
  type: :runtime
63
72
  prerelease: false
64
73
  version_requirements: !ruby/object:Gem::Requirement
65
74
  requirements:
66
75
  - - "~>"
67
76
  - !ruby/object:Gem::Version
68
- version: '2.3'
77
+ version: '3.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.1.1
69
81
  - !ruby/object:Gem::Dependency
70
- name: multipart-post
82
+ name: tracker_api
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
85
  - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: '2.0'
87
+ version: 0.2.12
76
88
  type: :runtime
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '2.0'
94
+ version: 0.2.12
83
95
  - !ruby/object:Gem::Dependency
84
- name: rest-client
96
+ name: bundler
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
99
  - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: '1.8'
90
- type: :runtime
101
+ version: '1.10'
102
+ type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
106
  - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: '1.8'
108
+ version: '1.10'
97
109
  - !ruby/object:Gem::Dependency
98
- name: ruby-keychain
110
+ name: rake
99
111
  requirement: !ruby/object:Gem::Requirement
100
112
  requirements:
101
- - - ">="
113
+ - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
115
+ version: '10.0'
116
+ type: :development
105
117
  prerelease: false
106
118
  version_requirements: !ruby/object:Gem::Requirement
107
119
  requirements:
108
- - - ">="
120
+ - - "~>"
109
121
  - !ruby/object:Gem::Version
110
- version: '0'
122
+ version: '10.0'
111
123
  - !ruby/object:Gem::Dependency
112
- name: pivotal-tracker
124
+ name: rspec
113
125
  requirement: !ruby/object:Gem::Requirement
114
126
  requirements:
115
127
  - - ">="
116
128
  - !ruby/object:Gem::Version
117
129
  version: '0'
118
- type: :runtime
130
+ type: :development
119
131
  prerelease: false
120
132
  version_requirements: !ruby/object:Gem::Requirement
121
133
  requirements:
@@ -123,13 +135,13 @@ dependencies:
123
135
  - !ruby/object:Gem::Version
124
136
  version: '0'
125
137
  - !ruby/object:Gem::Dependency
126
- name: harvested
138
+ name: pry
127
139
  requirement: !ruby/object:Gem::Requirement
128
140
  requirements:
129
141
  - - ">="
130
142
  - !ruby/object:Gem::Version
131
143
  version: '0'
132
- type: :runtime
144
+ type: :development
133
145
  prerelease: false
134
146
  version_requirements: !ruby/object:Gem::Requirement
135
147
  requirements:
@@ -137,63 +149,7 @@ dependencies:
137
149
  - !ruby/object:Gem::Version
138
150
  version: '0'
139
151
  - !ruby/object:Gem::Dependency
140
- name: tracker_api
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.2'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.2'
153
- - !ruby/object:Gem::Dependency
154
- name: faraday
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.9'
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '0.9'
167
- - !ruby/object:Gem::Dependency
168
- name: bundler
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.10'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.10'
181
- - !ruby/object:Gem::Dependency
182
- name: rake
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '10.0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '10.0'
195
- - !ruby/object:Gem::Dependency
196
- name: rspec
152
+ name: rubocop
197
153
  requirement: !ruby/object:Gem::Requirement
198
154
  requirements:
199
155
  - - ">="
@@ -207,7 +163,7 @@ dependencies:
207
163
  - !ruby/object:Gem::Version
208
164
  version: '0'
209
165
  - !ruby/object:Gem::Dependency
210
- name: pry
166
+ name: bump
211
167
  requirement: !ruby/object:Gem::Requirement
212
168
  requirements:
213
169
  - - ">="
@@ -221,7 +177,7 @@ dependencies:
221
177
  - !ruby/object:Gem::Version
222
178
  version: '0'
223
179
  - !ruby/object:Gem::Dependency
224
- name: rubocop
180
+ name: guard-rspec
225
181
  requirement: !ruby/object:Gem::Requirement
226
182
  requirements:
227
183
  - - ">="
@@ -248,6 +204,7 @@ files:
248
204
  - ".travis.yml"
249
205
  - CODE_OF_CONDUCT.md
250
206
  - Gemfile
207
+ - Guardfile
251
208
  - LICENSE.txt
252
209
  - README.md
253
210
  - Rakefile
@@ -255,6 +212,7 @@ files:
255
212
  - bin/setup
256
213
  - exe/get-to-work
257
214
  - get_to_work.gemspec
215
+ - lib/ext/string.rb
258
216
  - lib/get_to_work.rb
259
217
  - lib/get_to_work/cli.rb
260
218
  - lib/get_to_work/command.rb