lionel_richie 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # LionelRichie
2
2
 
3
- Trello? Is it me you're looking for?
3
+ LionelRichie is a script for exporting Trello data to Google Docs.
4
4
 
5
- LionelRichie is a script for exporting Trello data to Google Docs. This gem is in its very early stages so its probably not useful to you yet.
5
+ This gem is in its very early stages so its probably not useful to you yet.
6
+
7
+ ![lionel](https://www.evernote.com/shard/s111/sh/86ca745b-4e7e-4b06-9fd2-32112436c72b/19b422ac7bab8162f9268be34be85b2d/res/03b54478-c928-4732-8d6a-4b56bcc205dc/lionel-richie-trello.jpg?resizeSmall&width=832)
6
8
 
7
9
  ## Installation
8
10
 
data/lib/lionel/cli.rb CHANGED
@@ -1,35 +1,38 @@
1
1
  module Lionel
2
2
  class CLI < Thor
3
3
 
4
- def initialize(*)
5
- @configuration = Lionel::Configuration.instance
6
- super
7
- end
8
-
9
4
  desc "authorize PROVIDER", "Allows application to request user authorization for provider (google|trello)"
5
+ method_option "new-client", :aliases => "-n", :type => :boolean,
6
+ :default => false, :desc => "Set new google client credentials."
10
7
  def authorize(provider)
11
8
  case provider
12
9
  when 'trello'
13
10
  auth = Lionel::TrelloAuthentication.new
14
11
 
15
- Launchy.open(auth.trello_key_url)
16
- auth.trello_key = ask "Enter trello key:"
12
+ if options['new-client'] || !auth.configured?
13
+ Launchy.open(auth.trello_key_url)
14
+ auth.trello_key = ask "Enter trello key:"
17
15
 
18
- Launchy.open(auth.trello_token_url)
19
- auth.trello_token = ask "Enter trello token:"
16
+ Launchy.open(auth.trello_token_url)
17
+ auth.trello_token = ask "Enter trello token:"
20
18
 
21
- auth.save
19
+ auth.save_configuration
20
+ else
21
+ say "Trello is already configured. Run 'lionel authorize trello -n' to reset."
22
+ end
22
23
  when 'google'
23
24
  auth = Lionel::GoogleAuthentication.new
24
25
 
25
- Launchy.open(auth.api_console_url)
26
- auth.google_client_id = ask("Enter your google client id:")
27
- auth.google_client_secret = ask("Enter your google client secret:")
26
+ if options['new-client'] || !auth.configured?
27
+ Launchy.open(auth.api_console_url)
28
+ auth.google_client_id = ask("Enter your google client id:")
29
+ auth.google_client_secret = ask("Enter your google client secret:")
30
+ end
28
31
 
29
32
  Launchy.open(auth.authorize_url)
30
33
  auth.retrieve_access_token ask("Enter your google key:")
31
34
 
32
- auth.save
35
+ auth.save_configuration
33
36
  else
34
37
  "Provider not recognized: #{provider}"
35
38
  end
@@ -37,9 +40,9 @@ module Lionel
37
40
 
38
41
  desc "export", "Saves Trello export to Google Docs"
39
42
  method_option "print", :aliases => "-p", :type => :boolean, :default => false, :desc => "Print results instead of saving them to Google Docs."
40
- method_option "trello-board-id", :aliases => "-t", :type => :string, :default => nil, :desc => "Specify the Google Doc."
41
- method_option "google-doc-id", :aliases => "-g", :type => :string, :default => nil, :desc => "Print results instead of saving them to Google Docs."
42
- method_option "configure", :aliases => "-c", :type => :string, :default => true, :desc => "Save export configuration."
43
+ method_option "trello-board-id", :aliases => "-t", :type => :string, :default => nil, :desc => "Specify the source Trello board id."
44
+ method_option "google-doc-id", :aliases => "-g", :type => :string, :default => nil, :desc => "Specify the target Google doc id."
45
+ method_option "save", :aliases => "-c", :type => :string, :default => true, :desc => "Save the command line ids as the default configuration."
43
46
  def export
44
47
  export = Lionel::Export.new
45
48
 
@@ -55,7 +58,7 @@ module Lionel
55
58
  export.trello_board_id = ask("Enter a trello board id to export from:")
56
59
  end
57
60
 
58
- export.save if options['configure']
61
+ export.save_configuration if options['save']
59
62
 
60
63
  export.authenticate
61
64
 
@@ -8,7 +8,7 @@ module Lionel
8
8
  Configuration.instance
9
9
  end
10
10
 
11
- def save
11
+ def save_configuration
12
12
  configuration.save(data)
13
13
  end
14
14
 
@@ -16,13 +16,22 @@ module Lionel
16
16
  {}
17
17
  end
18
18
 
19
+ def configured?
20
+ self.class.config_accessors.all? { |accessor| !!send(accessor) }
21
+ end
19
22
  end
20
23
 
21
24
  module ClassMethods
22
25
 
26
+ def config_accessors
27
+ @config_accessors ||= []
28
+ end
29
+
23
30
  def config_accessor(*args)
24
31
  attr_writer(*args)
25
32
 
33
+ args.each { |accessor| config_accessors << accessor }
34
+
26
35
  args.each do |reader|
27
36
  define_method(reader) do
28
37
  instance_variable_get("@#{reader}") || configuration.send(reader)
data/lib/lionel/export.rb CHANGED
@@ -4,10 +4,6 @@ module Lionel
4
4
 
5
5
  config_accessor :google_doc_id, :trello_board_id
6
6
 
7
- def has_sources?
8
- trello_board_id && google_doc_id
9
- end
10
-
11
7
  def data
12
8
  {
13
9
  trello_board_id: trello_board_id,
@@ -2,7 +2,8 @@ module Lionel
2
2
  class GoogleAuthentication
3
3
  include Configurable
4
4
 
5
- attr_reader :access_token
5
+ attr_accessor :access_token
6
+ attr_writer :client
6
7
  config_accessor :google_client_id, :google_client_secret
7
8
 
8
9
  def data
@@ -41,8 +42,6 @@ module Lionel
41
42
  "https://code.google.com/apis/console"
42
43
  end
43
44
 
44
- private
45
-
46
45
  def client
47
46
  @client ||= OAuth2::Client.new(google_client_id, google_client_secret,
48
47
  :site => "https://accounts.google.com",
@@ -50,6 +49,8 @@ module Lionel
50
49
  :authorize_url => "/o/oauth2/auth")
51
50
  end
52
51
 
52
+ private
53
+
53
54
  def refresh_token
54
55
  @refresh_token || configuration.google_refresh_token
55
56
  end
@@ -11,8 +11,10 @@ module Lionel
11
11
  %Q[=HYPERLINK("#{card.url}", "#{card.name.gsub(/"/, "")}")]
12
12
  end
13
13
 
14
- def actions
15
- @actions ||= card.actions.map { |a| Lionel::ProxyAction.new(a) }
14
+ MAX_ACTIONS = 1000
15
+ def actions(options = {})
16
+ options[:limit] = options.fetch(:limit, MAX_ACTIONS)
17
+ @actions ||= card.actions(options).map { |a| Lionel::ProxyAction.new(a) }
16
18
  end
17
19
 
18
20
  def action_date(&block)
@@ -1,3 +1,3 @@
1
1
  module Lionel
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "launchy"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.3"
31
+ spec.add_development_dependency "rspec"
32
+ spec.add_development_dependency "guard-rspec"
31
33
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lionel::Export do
4
+
5
+ describe "configuration" do
6
+ before(:each) do
7
+ subject.trello_board_id = "TRELLO_BOARD_ID"
8
+ subject.google_doc_id = "GOOGLE_DOC_ID"
9
+ end
10
+
11
+ it {
12
+ subject.data.should eq({
13
+ trello_board_id: "TRELLO_BOARD_ID",
14
+ google_doc_id: "GOOGLE_DOC_ID"
15
+ })
16
+ }
17
+
18
+ it "can save the configuration data" do
19
+ subject.configuration.should_receive(:save).with(subject.data)
20
+ subject.save_configuration
21
+ end
22
+
23
+ it { subject.should be_configured }
24
+
25
+ context "not configured" do
26
+ before do
27
+ subject.configuration.stub(trello_board_id: nil, google_doc_id: nil)
28
+ end
29
+
30
+ it { subject.trello_board_id = nil;
31
+ subject.should_not be_configured }
32
+ it { subject.google_doc_id = nil;
33
+ subject.should_not be_configured }
34
+ it { subject.trello_board_id = nil;
35
+ subject.google_doc_id = nil;
36
+ subject.should_not be_configured }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lionel::GoogleAuthentication do
4
+ let(:access_token) {
5
+ double('OAuth2::AccessToken', token: "GOOGLE_TOKEN", refresh_token: "GOOGLE_REFRESH_TOKEN")
6
+ }
7
+
8
+ it {
9
+ subject.api_console_url.should eq("https://code.google.com/apis/console")
10
+ }
11
+
12
+ describe "configuration" do
13
+ before(:each) do
14
+ subject.access_token = access_token
15
+ subject.google_client_id = "GOOGLE_CLIENT_ID"
16
+ subject.google_client_secret = "GOOGLE_CLIENT_SECRET"
17
+ end
18
+
19
+ it {
20
+ subject.data.should eq({
21
+ google_token: "GOOGLE_TOKEN",
22
+ google_refresh_token: "GOOGLE_REFRESH_TOKEN",
23
+ google_client_id: "GOOGLE_CLIENT_ID",
24
+ google_client_secret: "GOOGLE_CLIENT_SECRET"
25
+ })
26
+ }
27
+
28
+ it "can save the configuration data" do
29
+ subject.configuration.should_receive(:save).with(subject.data)
30
+ subject.save_configuration
31
+ end
32
+
33
+ it "creates new Oauth2 client" do
34
+ OAuth2::Client.should_receive(:new).with(
35
+ "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET",
36
+ :site => "https://accounts.google.com",
37
+ :token_url => "/o/oauth2/token",
38
+ :authorize_url => "/o/oauth2/auth")
39
+ subject.client
40
+ end
41
+
42
+ it { subject.should be_configured }
43
+
44
+ context "not configured" do
45
+ before do
46
+ subject.configuration.stub(google_client_id: nil, google_client_secret: nil)
47
+ end
48
+
49
+ it { subject.google_client_id = nil;
50
+ subject.should_not be_configured }
51
+ it { subject.google_client_secret = nil;
52
+ subject.should_not be_configured }
53
+ it { subject.google_client_id = nil;
54
+ subject.google_client_secret = nil;
55
+ subject.should_not be_configured }
56
+ end
57
+ end
58
+
59
+ describe "oauth2" do
60
+ let(:auth_code) { double('OAuth2::AuthCode', :authorize_url => "http://example.com") }
61
+ let(:client) { double('OAuth2::Client', auth_code: auth_code) }
62
+
63
+ before(:each) do
64
+ subject.google_client_id = "GOOGLE_CLIENT_ID"
65
+ subject.google_client_secret = "GOOGLE_CLIENT_SECRET"
66
+ subject.client = client
67
+ end
68
+
69
+ it "retrieves oauth2 authorize_url" do
70
+ auth_code.should_receive(:authorize_url).with(
71
+ :redirect_uri => "urn:ietf:wg:oauth:2.0:oob",
72
+ :scope =>
73
+ "https://docs.google.com/feeds/ " +
74
+ "https://docs.googleusercontent.com/ " +
75
+ "https://spreadsheets.google.com/feeds/")
76
+ subject.authorize_url
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lionel::TrelloAuthentication do
4
+ it {
5
+ subject.trello_key_url.should eq("https://trello.com/1/appKey/generate")
6
+ }
7
+ it {
8
+ subject.trello_token_url("TOKEN").should eq("https://trello.com/1/authorize?key=TOKEN&name=LionelRichie&response_type=token&scope=read,write,account&expiration=never")
9
+ }
10
+ it { subject.app_name.should eq("LionelRichie") }
11
+
12
+ describe "configuration" do
13
+ before(:each) do
14
+ subject.trello_key = "TRELLO_KEY"
15
+ subject.trello_token = "TRELLO_TOKEN"
16
+ end
17
+
18
+ it {
19
+ subject.data.should eq({
20
+ trello_key: "TRELLO_KEY",
21
+ trello_token: "TRELLO_TOKEN"
22
+ })
23
+ }
24
+
25
+ it "can onfigure the Trello api" do
26
+ subject.configure
27
+ Trello.auth_policy.developer_public_key.should eq("TRELLO_KEY")
28
+ Trello.auth_policy.member_token.should eq("TRELLO_TOKEN")
29
+ end
30
+
31
+ it "can save the configuration data" do
32
+ subject.configuration.should_receive(:save).with(subject.data)
33
+ subject.save_configuration
34
+ end
35
+
36
+ it { subject.should be_configured }
37
+
38
+ context "not configured" do
39
+ before do
40
+ subject.configuration.stub(trello_key: nil, trello_token: nil)
41
+ end
42
+
43
+ it { subject.trello_key = nil;
44
+ subject.should_not be_configured }
45
+ it { subject.trello_token = nil;
46
+ subject.should_not be_configured }
47
+ it { subject.trello_key = nil;
48
+ subject.trello_token = nil;
49
+ subject.should_not be_configured }
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'lionel_richie'
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+
10
+ # Run specs in random order to surface order dependencies. If you find an
11
+ # order dependency and want to debug it, you can fix the order by providing
12
+ # the seed, which is printed after each run.
13
+ # --seed 1234
14
+ config.order = 'random'
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lionel_richie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,6 +107,38 @@ dependencies:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: '1.3'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
110
142
  description: Export Trello to Google Docs
111
143
  email:
112
144
  - rosskaff@gmail.com
@@ -116,7 +148,9 @@ extensions: []
116
148
  extra_rdoc_files: []
117
149
  files:
118
150
  - .gitignore
151
+ - .rspec
119
152
  - Gemfile
153
+ - Guardfile
120
154
  - LICENSE.txt
121
155
  - README.md
122
156
  - Rakefile
@@ -135,6 +169,10 @@ files:
135
169
  - lib/lionel_richie.rb
136
170
  - lionel_richie.gemspec
137
171
  - script/console
172
+ - spec/lib/lionel/export_spec.rb
173
+ - spec/lib/lionel/google_authentication_spec.rb
174
+ - spec/lib/lionel/trello_authentication_spec.rb
175
+ - spec/spec_helper.rb
138
176
  homepage: ''
139
177
  licenses:
140
178
  - MIT
@@ -160,4 +198,8 @@ rubygems_version: 1.8.25
160
198
  signing_key:
161
199
  specification_version: 3
162
200
  summary: Export Trello to Google Docs
163
- test_files: []
201
+ test_files:
202
+ - spec/lib/lionel/export_spec.rb
203
+ - spec/lib/lionel/google_authentication_spec.rb
204
+ - spec/lib/lionel/trello_authentication_spec.rb
205
+ - spec/spec_helper.rb