todoplicator 0.0.1 → 0.1.0

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
  SHA256:
3
- metadata.gz: 21ac029aaed7a2c16f49e6d921cad1a805417642cbb85a310a988031d9adc044
4
- data.tar.gz: 9f30f1722f902da47b61e71fa90b7a7574a3e619e1c1d9c92e182a2650c5cb5a
3
+ metadata.gz: 4b026c30abcee751f7beda801d7a64dbddd7d94e70f6924848fd3574f313b605
4
+ data.tar.gz: 8fefedfdf0b8c1f117139a83df2ec7df49c36ca4e23088e6eae888a2a08fac58
5
5
  SHA512:
6
- metadata.gz: 936253f33f5a2b09dffb4cbdfc977b64111e3313391987e9e728ab9982a4fe791e20a25e66af3e7ccbb28545051406950565757ca7de69e15bd7663e7f3d22c4
7
- data.tar.gz: 571e0d8e97d3379a9cba2ebe8ff8247999f4601d590e32bbfe6ab1a398b4479932c3a6b88ae9a3f170eea44489d4775f3fc3a7d75508752293d42eb15c01e16f
6
+ metadata.gz: 9f6b355f5d58e80feefe674308445865853b5ef091ba17f6edd545fbe4566600a336ac7c785680a4a7747542ca08e412be5d5aec888e4fe033406a414b809145
7
+ data.tar.gz: '08d67e3af63dfe68ca2ade2d425f771059cffbfe5b9bfa0bee3aa24c7af6a8aa8e15178c77ae6392d016dd581a6c2ab1eb2fa195a42552906d89929661298ae0'
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,234 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-06-20 17:50:56 -0400 using RuboCop version 0.57.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
+ # Include: **/*.gemspec
13
+ Gemspec/OrderedDependencies:
14
+ Exclude:
15
+ - 'todoplicator.gemspec'
16
+
17
+ # Offense count: 5
18
+ # Cop supports --auto-correct.
19
+ # Configuration parameters: IndentationWidth.
20
+ # SupportedStyles: outdent, indent
21
+ Layout/AccessModifierIndentation:
22
+ EnforcedStyle: outdent
23
+
24
+ # Offense count: 9
25
+ # Cop supports --auto-correct.
26
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
27
+ # SupportedStyles: with_first_parameter, with_fixed_indentation
28
+ Layout/AlignParameters:
29
+ Exclude:
30
+ - 'bin/_guard-core'
31
+ - 'bin/guard'
32
+ - 'bin/rake'
33
+ - 'bin/rspec'
34
+ - 'bin/rubocop'
35
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
36
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
37
+
38
+ # Offense count: 4
39
+ # Cop supports --auto-correct.
40
+ Layout/BlockEndNewline:
41
+ Exclude:
42
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
43
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
44
+
45
+ # Offense count: 4
46
+ # Cop supports --auto-correct.
47
+ Layout/MultilineBlockLayout:
48
+ Exclude:
49
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
50
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
51
+
52
+ # Offense count: 3
53
+ # Cop supports --auto-correct.
54
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
55
+ # SupportedStyles: space, no_space
56
+ # SupportedStylesForEmptyBraces: space, no_space
57
+ Layout/SpaceInsideBlockBraces:
58
+ Exclude:
59
+ - 'Gemfile'
60
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
61
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
62
+
63
+ # Offense count: 16
64
+ # Cop supports --auto-correct.
65
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
66
+ # SupportedStyles: space, no_space, compact
67
+ # SupportedStylesForEmptyBraces: space, no_space
68
+ Layout/SpaceInsideHashLiteralBraces:
69
+ Exclude:
70
+ - 'spec/spec_helper.rb'
71
+ - 'spec/todoplicator/adapter_registry_spec.rb'
72
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
73
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
74
+ - 'spec/todoplicator_spec.rb'
75
+
76
+ # Offense count: 1
77
+ # Cop supports --auto-correct.
78
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
79
+ Lint/UnusedBlockArgument:
80
+ Exclude:
81
+ - 'exe/todoplicator'
82
+
83
+ # Offense count: 1
84
+ Metrics/AbcSize:
85
+ Max: 18
86
+
87
+ # Offense count: 6
88
+ # Configuration parameters: CountComments, ExcludedMethods.
89
+ Metrics/BlockLength:
90
+ Max: 72
91
+
92
+ # Offense count: 1
93
+ Metrics/CyclomaticComplexity:
94
+ Max: 9
95
+
96
+ # Offense count: 2
97
+ # Configuration parameters: CountComments.
98
+ Metrics/MethodLength:
99
+ Max: 13
100
+
101
+ # Offense count: 1
102
+ Metrics/PerceivedComplexity:
103
+ Max: 9
104
+
105
+ # Offense count: 5
106
+ # Cop supports --auto-correct.
107
+ Performance/RegexpMatch:
108
+ Exclude:
109
+ - 'bin/_guard-core'
110
+ - 'bin/guard'
111
+ - 'bin/rake'
112
+ - 'bin/rspec'
113
+ - 'bin/rubocop'
114
+
115
+ # Offense count: 4
116
+ # Cop supports --auto-correct.
117
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
118
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining
119
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
120
+ # FunctionalMethods: let, let!, subject, watch
121
+ # IgnoredMethods: lambda, proc, it
122
+ Style/BlockDelimiters:
123
+ Exclude:
124
+ - 'spec/todoplicator/git_hub_adapter_spec.rb'
125
+ - 'spec/todoplicator/git_lab_adapter_spec.rb'
126
+
127
+ # Offense count: 1
128
+ # Cop supports --auto-correct.
129
+ # Configuration parameters: EnforcedStyle.
130
+ # SupportedStyles: braces, no_braces, context_dependent
131
+ Style/BracesAroundHashParameters:
132
+ Exclude:
133
+ - 'spec/todoplicator/adapter_registry_spec.rb'
134
+
135
+ # Offense count: 1
136
+ Style/ClassVars:
137
+ Exclude:
138
+ - 'lib/todoplicator/adapter_registry.rb'
139
+
140
+ # Offense count: 7
141
+ Style/Documentation:
142
+ Exclude:
143
+ - 'spec/**/*'
144
+ - 'test/**/*'
145
+ - 'lib/todoplicator.rb'
146
+ - 'lib/todoplicator/adapter_registry.rb'
147
+ - 'lib/todoplicator/find_adapter.rb'
148
+ - 'lib/todoplicator/git_hub_adapter.rb'
149
+ - 'lib/todoplicator/git_lab_adapter.rb'
150
+
151
+ # Offense count: 1
152
+ # Cop supports --auto-correct.
153
+ # Configuration parameters: EnforcedStyle.
154
+ # SupportedStyles: compact, expanded
155
+ Style/EmptyMethod:
156
+ Exclude:
157
+ - 'spec/todoplicator/find_adapter_spec.rb'
158
+
159
+ # Offense count: 8
160
+ # Cop supports --auto-correct.
161
+ Style/ExpandPathArguments:
162
+ Exclude:
163
+ - 'bin/_guard-core'
164
+ - 'bin/bundle'
165
+ - 'bin/guard'
166
+ - 'bin/rake'
167
+ - 'bin/rspec'
168
+ - 'bin/rubocop'
169
+ - 'todoplicator.gemspec'
170
+
171
+ # Offense count: 17
172
+ # Cop supports --auto-correct.
173
+ # Configuration parameters: EnforcedStyle.
174
+ # SupportedStyles: when_needed, always, never
175
+ Style/FrozenStringLiteralComment:
176
+ Enabled: false
177
+
178
+ # Offense count: 1
179
+ # Cop supports --auto-correct.
180
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
181
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
182
+ Style/HashSyntax:
183
+ Exclude:
184
+ - 'Rakefile'
185
+
186
+ # Offense count: 3
187
+ # Cop supports --auto-correct.
188
+ Style/IfUnlessModifier:
189
+ Exclude:
190
+ - 'bin/bundle'
191
+
192
+ # Offense count: 1
193
+ # Cop supports --auto-correct.
194
+ Style/PerlBackrefs:
195
+ Exclude:
196
+ - 'bin/bundle'
197
+
198
+ # Offense count: 2
199
+ # Cop supports --auto-correct.
200
+ # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
201
+ # SupportedStyles: slashes, percent_r, mixed
202
+ Style/RegexpLiteral:
203
+ Exclude:
204
+ - 'lib/todoplicator/find_adapter.rb'
205
+
206
+ # Offense count: 1
207
+ # Cop supports --auto-correct.
208
+ # Configuration parameters: EnforcedStyle.
209
+ # SupportedStyles: use_perl_names, use_english_names
210
+ Style/SpecialGlobalVars:
211
+ Exclude:
212
+ - 'bin/bundle'
213
+
214
+ # Offense count: 231
215
+ # Cop supports --auto-correct.
216
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
217
+ # SupportedStyles: single_quotes, double_quotes
218
+ Style/StringLiterals:
219
+ Enabled: false
220
+
221
+ # Offense count: 2
222
+ # Cop supports --auto-correct.
223
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
224
+ # Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
225
+ Style/TrivialAccessors:
226
+ Exclude:
227
+ - 'lib/todoplicator/git_hub_adapter.rb'
228
+ - 'lib/todoplicator/git_lab_adapter.rb'
229
+
230
+ # Offense count: 31
231
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
232
+ # URISchemes: http, https
233
+ Metrics/LineLength:
234
+ Max: 190
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ ruby '2.5.1'
4
+
3
5
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in todoplicator.gemspec
data/Gemfile.lock CHANGED
@@ -1,13 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Todoplicator (0.0.0)
4
+ todoplicator (0.1.0)
5
+ gitlab (~> 4.4)
6
+ octokit (~> 4.0)
5
7
 
6
8
  GEM
7
9
  remote: https://rubygems.org/
8
10
  specs:
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ ast (2.4.0)
14
+ coderay (1.1.2)
15
+ crack (0.4.3)
16
+ safe_yaml (~> 1.0.0)
9
17
  diff-lcs (1.3)
18
+ docile (1.3.1)
19
+ faraday (0.15.2)
20
+ multipart-post (>= 1.2, < 3)
21
+ ffi (1.9.25)
22
+ formatador (0.2.5)
23
+ gitlab (4.4.0)
24
+ httparty (>= 0.14.0)
25
+ terminal-table (>= 1.5.1)
26
+ guard (2.14.2)
27
+ formatador (>= 0.2.4)
28
+ listen (>= 2.7, < 4.0)
29
+ lumberjack (>= 1.0.12, < 2.0)
30
+ nenv (~> 0.1)
31
+ notiffany (~> 0.0)
32
+ pry (>= 0.9.12)
33
+ shellany (~> 0.0)
34
+ thor (>= 0.18.1)
35
+ guard-compat (1.2.1)
36
+ guard-rspec (4.7.3)
37
+ guard (~> 2.1)
38
+ guard-compat (~> 1.1)
39
+ rspec (>= 2.99.0, < 4.0)
40
+ hashdiff (0.3.7)
41
+ httparty (0.16.2)
42
+ multi_xml (>= 0.5.2)
43
+ jaro_winkler (1.5.1)
44
+ json (2.1.0)
45
+ listen (3.1.5)
46
+ rb-fsevent (~> 0.9, >= 0.9.4)
47
+ rb-inotify (~> 0.9, >= 0.9.7)
48
+ ruby_dep (~> 1.2)
49
+ lumberjack (1.0.13)
50
+ method_source (0.9.0)
51
+ multi_xml (0.6.0)
52
+ multipart-post (2.0.0)
53
+ nenv (0.3.0)
54
+ notiffany (0.1.1)
55
+ nenv (~> 0.1)
56
+ shellany (~> 0.0)
57
+ octokit (4.9.0)
58
+ sawyer (~> 0.8.0, >= 0.5.3)
59
+ parallel (1.12.1)
60
+ parser (2.5.1.0)
61
+ ast (~> 2.4.0)
62
+ powerpack (0.1.2)
63
+ pry (0.11.3)
64
+ coderay (~> 1.1.0)
65
+ method_source (~> 0.9.0)
66
+ pry-doc (0.13.4)
67
+ pry (~> 0.11)
68
+ yard (~> 0.9.11)
69
+ public_suffix (3.0.2)
70
+ rainbow (3.0.0)
10
71
  rake (10.5.0)
72
+ rb-fsevent (0.10.3)
73
+ rb-inotify (0.9.10)
74
+ ffi (>= 0.5.0, < 2)
11
75
  rspec (3.7.0)
12
76
  rspec-core (~> 3.7.0)
13
77
  rspec-expectations (~> 3.7.0)
@@ -21,15 +85,56 @@ GEM
21
85
  diff-lcs (>= 1.2.0, < 2.0)
22
86
  rspec-support (~> 3.7.0)
23
87
  rspec-support (3.7.1)
88
+ rubocop (0.57.2)
89
+ jaro_winkler (~> 1.5.1)
90
+ parallel (~> 1.10)
91
+ parser (>= 2.5)
92
+ powerpack (~> 0.1)
93
+ rainbow (>= 2.2.2, < 4.0)
94
+ ruby-progressbar (~> 1.7)
95
+ unicode-display_width (~> 1.0, >= 1.0.1)
96
+ ruby-progressbar (1.9.0)
97
+ ruby_dep (1.5.0)
98
+ safe_yaml (1.0.4)
99
+ sawyer (0.8.1)
100
+ addressable (>= 2.3.5, < 2.6)
101
+ faraday (~> 0.8, < 1.0)
102
+ shellany (0.0.1)
103
+ simplecov (0.16.1)
104
+ docile (~> 1.1)
105
+ json (>= 1.8, < 3)
106
+ simplecov-html (~> 0.10.0)
107
+ simplecov-html (0.10.2)
108
+ terminal-notifier-guard (1.7.0)
109
+ terminal-table (1.8.0)
110
+ unicode-display_width (~> 1.1, >= 1.1.1)
111
+ thor (0.20.0)
112
+ unicode-display_width (1.4.0)
113
+ vcr (3.0.3)
114
+ webmock (2.3.2)
115
+ addressable (>= 2.3.6)
116
+ crack (>= 0.3.2)
117
+ hashdiff
118
+ yard (0.9.14)
24
119
 
25
120
  PLATFORMS
26
121
  ruby
27
122
 
28
123
  DEPENDENCIES
29
- Todoplicator!
30
124
  bundler (~> 1.16)
125
+ guard-rspec (~> 4.7)
126
+ pry-doc (~> 0.13)
31
127
  rake (~> 10.0)
32
128
  rspec (~> 3.0)
129
+ rubocop (~> 0.57)
130
+ simplecov (~> 0.16)
131
+ terminal-notifier-guard (~> 1.7)
132
+ todoplicator!
133
+ vcr (~> 3.0)
134
+ webmock (~> 2.1)
135
+
136
+ RUBY VERSION
137
+ ruby 2.5.1p57
33
138
 
34
139
  BUNDLED WITH
35
140
  1.16.2
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :rspec, cmd: 'bin/rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+ notification :terminal_notifier if `uname` =~ /Darwin/
data/README.md CHANGED
@@ -1,38 +1,121 @@
1
1
  # Todoplicator
2
+ [![Build Status](https://travis-ci.com/jfine/todoplicator.svg?token=zextiA39ne5EAbQqQxVu&branch=master)](https://travis-ci.com/jfine/todoplicator)
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/todoplicator`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+ Duplicate to-dos between popular to-do tools.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ Todoplicator currently copies issue titles, bodies (or descriptions), and state
7
+ (closed or open).
6
8
 
7
9
  ## Installation
8
10
 
9
- Add this line to your application's Gemfile:
11
+ Add to Gemfile:
10
12
 
11
13
  ```ruby
12
- gem 'todoplicator'
14
+ gem "todoplicator"
13
15
  ```
14
16
 
15
- And then execute:
17
+ Then bundle:
16
18
 
17
- $ bundle
19
+ ```
20
+ $ bundle
21
+ ```
18
22
 
19
- Or install it yourself as:
23
+ Or install in system gems:
20
24
 
21
- $ gem install todoplicator
25
+ ```
26
+ $ gem install todoplicator
27
+ ```
22
28
 
23
29
  ## Usage
24
30
 
25
- TODO: Write usage instructions here
31
+ ### Adapters
32
+
33
+ Below are the currently supported adapters. They are used to identify the source
34
+ and destination for issues to be copied.
35
+
36
+ |Class|Key|Target|Token|
37
+ |-|-|-|-|
38
+ |GitHubAdapter|github|username/repository|GITHUB_TOKEN|
39
+ |GitLabAdapter|gitlab|username/repository|GITLAB_TOKEN|
40
+
41
+ ### Examples
42
+
43
+ For each adapter you plan on using you must have created a token that has
44
+ permission to either read or write from the source or destination for issues
45
+ to be copied.
46
+
47
+ Todoplicator must be installed and the appropriate authentication set via
48
+ environment variable. There are multiple ways to set environment variables
49
+ for applications.
50
+
51
+ The simplest approach is to export them before you run your script:
52
+
53
+ ```
54
+ $ export GITHUB_TOKEN=abc123
55
+ ```
56
+
57
+ #### Ruby
58
+
59
+ Copy from one GitHub repository to another:
60
+
61
+ ```ruby
62
+ require "todoplicator"
63
+ Todoplicator.new("github/jfine/todo-source", "github/jfine/todo-destination").copy
64
+ ```
65
+
66
+ Copy from GitLab to GitHub repository:
67
+
68
+ ```ruby
69
+ require "todoplicator"
70
+ Todoplicator.new("gitlab/jfine/todo-source", "github/jfine/todo-destination").copy
71
+ ```
72
+
73
+ #### Command line
74
+
75
+ Display help:
76
+
77
+ ```
78
+ $ todoplicator -h
79
+ ```
80
+
81
+ Copy from one GitHub repository to another:
82
+
83
+ ```
84
+ $ todoplicator github/jfine/todo-source github/jfine/todo-destination
85
+ ```
86
+
87
+ Copy from GitLab to GitHub repository:
88
+
89
+ ```
90
+ $ todoplicator gitlab/jfine/todo-source github/jfine/todo-destination
91
+ ```
26
92
 
27
93
  ## Development
28
94
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
95
+ For an overview of considerations, thoughts, and general guidelines please see the issues below.
96
+
97
+ - [Research command line Ruby frameworks, tools, accepted practices ](https://github.com/jfine/todoplicator/issues/1#issuecomment-398195906)
30
98
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
+ Although all commands can be run via `bundle execute` several have been added as binstubs
100
+ for convenience and for use by tools such as RVM, direnv, etc.
101
+
102
+ - `bin/console` for starting an interactive prompt
103
+ - `bin/guard` for automatic running of specs
104
+ - `bin/rake` for running other tasks including gem building and publishing
105
+ - `bin/rspec` for running specs
106
+ - `bin/rubocop` for code linting
107
+
108
+ ### Setup
109
+
110
+ ```
111
+ $ git clone git@github.com:jfine/todoplicator.git
112
+ $ cd todoplicator
113
+ $ bin/setup
114
+ ```
32
115
 
33
116
  ## Contributing
34
117
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/todoplicator.
118
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jfine/todoplicator.
36
119
 
37
120
  ## License
38
121
 
data/bin/_guard-core ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application '_guard-core' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "_guard-core")
data/bin/bundle ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1 || ">= 0.a"
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||= begin
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version || "#{Gem::Requirement.default}.a"
67
+ end
68
+ end
69
+
70
+ def load_bundler!
71
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
72
+
73
+ # must dup string for RG < 1.8 compatibility
74
+ activate_bundler(bundler_version.dup)
75
+ end
76
+
77
+ def activate_bundler(bundler_version)
78
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
+ bundler_version = "< 2"
80
+ end
81
+ gem_error = activation_error_handling do
82
+ gem "bundler", bundler_version
83
+ end
84
+ return if gem_error.nil?
85
+ require_error = activation_error_handling do
86
+ require "bundler/version"
87
+ end
88
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
+ exit 42
91
+ end
92
+
93
+ def activation_error_handling
94
+ yield
95
+ nil
96
+ rescue StandardError, LoadError => e
97
+ e
98
+ end
99
+ end
100
+
101
+ m.load_bundler!
102
+
103
+ if m.invoked_as_script?
104
+ load Gem.bin_path("bundler", "bundle")
105
+ end
data/bin/guard ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'guard' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "guard")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/exe/todoplicator ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "todoplicator"
5
+
6
+ OptionParser.new do |parser|
7
+ parser.banner = "Usage: todoplicator [options] SOURCE DESTINATION"
8
+
9
+ parser.on("-h", "--help", "Show this help message") do |value|
10
+ puts parser
11
+ exit
12
+ end
13
+ end.parse!
14
+
15
+ source, destination = ARGV[0..1]
16
+
17
+ puts "Copying issues from [#{source}] to [#{destination}]..."
18
+
19
+ Todoplicator.new(source, destination).copy.each do |issue|
20
+ puts "Copied [#{issue.title}]"
21
+ end
@@ -0,0 +1,27 @@
1
+ class Todoplicator
2
+ class AdapterRegistry
3
+ def self.instance
4
+ @@instance ||= new
5
+ end
6
+
7
+ def initialize
8
+ reset!
9
+ end
10
+
11
+ def add(key, klass)
12
+ @adapters[key.to_sym] = klass
13
+ end
14
+
15
+ def for(key)
16
+ @adapters.fetch(key.to_sym) { raise UnknownAdapter, "#{key} not found" }
17
+ end
18
+
19
+ def all
20
+ @adapters
21
+ end
22
+
23
+ def reset!
24
+ @adapters = {}
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ class Todoplicator
2
+ class FindAdapter
3
+ def self.call(*args)
4
+ new(*args).call
5
+ end
6
+
7
+ def initialize(location)
8
+ @location = location
9
+ end
10
+
11
+ def call
12
+ klass.new(target)
13
+ end
14
+
15
+ private
16
+
17
+ def klass
18
+ AdapterRegistry.instance.for(@location[/^([^\/]+)/, 1])
19
+ end
20
+
21
+ def target
22
+ @location[/^[^\/]+\/(.+)$/, 1]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,59 @@
1
+ require "octokit"
2
+
3
+ class Todoplicator
4
+ class GitHubAdapter
5
+ class Issue
6
+ def initialize(raw)
7
+ @raw = raw
8
+ end
9
+
10
+ def title
11
+ @raw.title
12
+ end
13
+
14
+ def body
15
+ @raw.body
16
+ end
17
+
18
+ def state
19
+ @raw.state
20
+ end
21
+
22
+ def raw
23
+ @raw
24
+ end
25
+
26
+ def closed?
27
+ state == "closed"
28
+ end
29
+
30
+ def open?
31
+ state == "open"
32
+ end
33
+ end
34
+
35
+ AdapterRegistry.instance.add(:github, GitHubAdapter)
36
+
37
+ def initialize(target)
38
+ @target = target
39
+ end
40
+
41
+ def find_issues
42
+ client.list_issues(@target, state: :all).map { |i| Issue.new(i) }
43
+ end
44
+
45
+ def create_issue(issue)
46
+ new_issue = Issue.new(client.create_issue(@target, issue.title, issue.body))
47
+ new_issue = Issue.new(client.close_issue(@target, new_issue.raw.number)) if issue.closed?
48
+ new_issue
49
+ end
50
+
51
+ private
52
+
53
+ def client
54
+ @client ||= Octokit::Client.new(
55
+ access_token: ENV["GITHUB_TOKEN"].to_s
56
+ )
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,60 @@
1
+ require "gitlab"
2
+
3
+ class Todoplicator
4
+ class GitLabAdapter
5
+ class Issue
6
+ def initialize(raw)
7
+ @raw = raw
8
+ end
9
+
10
+ def title
11
+ @raw.title
12
+ end
13
+
14
+ def body
15
+ @raw.description
16
+ end
17
+
18
+ def state
19
+ @raw.state
20
+ end
21
+
22
+ def raw
23
+ @raw
24
+ end
25
+
26
+ def closed?
27
+ state == "closed"
28
+ end
29
+
30
+ def open?
31
+ state == "opened"
32
+ end
33
+ end
34
+
35
+ AdapterRegistry.instance.add(:gitlab, GitLabAdapter)
36
+
37
+ def initialize(target)
38
+ @target = target
39
+ end
40
+
41
+ def find_issues
42
+ client.issues(@target).map { |i| Issue.new(i) }
43
+ end
44
+
45
+ def create_issue(issue)
46
+ new_issue = Issue.new(client.create_issue(@target, issue.title, description: issue.body))
47
+ new_issue = Issue.new(client.close_issue(@target, new_issue.raw.iid)) if issue.closed?
48
+ new_issue
49
+ end
50
+
51
+ private
52
+
53
+ def client
54
+ @client ||= Gitlab.client(
55
+ endpoint: "https://gitlab.com/api/v4",
56
+ private_token: ENV["GITLAB_TOKEN"].to_s
57
+ )
58
+ end
59
+ end
60
+ end
data/lib/todoplicator.rb CHANGED
@@ -1,5 +1,27 @@
1
- require "todoplicator/version"
1
+ require "todoplicator/adapter_registry"
2
+ require "todoplicator/find_adapter"
3
+ require "todoplicator/git_hub_adapter"
4
+ require "todoplicator/git_lab_adapter"
2
5
 
3
- module Todoplicator
4
- # Your code goes here...
6
+ class Todoplicator
7
+ class UnknownAdapter < StandardError; end
8
+
9
+ def initialize(source, destination)
10
+ @source = FindAdapter.call(source)
11
+ @destination = FindAdapter.call(destination)
12
+ end
13
+
14
+ def copy
15
+ issues_to_copy.map { |i| create_issue(i) }
16
+ end
17
+
18
+ private
19
+
20
+ def issues_to_copy
21
+ @source.find_issues
22
+ end
23
+
24
+ def create_issue(issue)
25
+ @destination.create_issue(issue)
26
+ end
5
27
  end
data/todoplicator.gemspec CHANGED
@@ -1,11 +1,9 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "todoplicator/version"
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = "todoplicator"
8
- spec.version = Todoplicator::VERSION
6
+ spec.version = "0.1.0"
9
7
  spec.authors = ["Jared Fine"]
10
8
  spec.email = ["jared@jfine.org"]
11
9
  spec.summary = "Duplicate to-dos between popular to-do tools."
@@ -21,4 +19,14 @@ Gem::Specification.new do |spec|
21
19
  spec.add_development_dependency "bundler", "~> 1.16"
22
20
  spec.add_development_dependency "rake", "~> 10.0"
23
21
  spec.add_development_dependency "rspec", "~> 3.0"
22
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
23
+ spec.add_development_dependency "terminal-notifier-guard", "~> 1.7"
24
+ spec.add_development_dependency "pry-doc", "~> 0.13"
25
+ spec.add_development_dependency "vcr", "~> 3.0"
26
+ spec.add_development_dependency "webmock", "~> 2.1"
27
+ spec.add_development_dependency "rubocop", "~> 0.57"
28
+ spec.add_development_dependency "simplecov", "~> 0.16"
29
+
30
+ spec.add_runtime_dependency "octokit", "~> 4.0"
31
+ spec.add_runtime_dependency "gitlab", "~> 4.4"
24
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todoplicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Fine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-18 00:00:00.000000000 Z
11
+ date: 2018-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,25 +52,165 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: terminal-notifier-guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-doc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.57'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.57'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.16'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.16'
153
+ - !ruby/object:Gem::Dependency
154
+ name: octokit
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '4.0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '4.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: gitlab
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '4.4'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '4.4'
55
181
  description:
56
182
  email:
57
183
  - jared@jfine.org
58
- executables: []
184
+ executables:
185
+ - todoplicator
59
186
  extensions: []
60
187
  extra_rdoc_files: []
61
188
  files:
62
189
  - ".gitignore"
63
190
  - ".rspec"
191
+ - ".rubocop.yml"
192
+ - ".rubocop_todo.yml"
64
193
  - ".travis.yml"
65
194
  - Gemfile
66
195
  - Gemfile.lock
196
+ - Guardfile
67
197
  - LICENSE.txt
68
198
  - README.md
69
199
  - Rakefile
200
+ - bin/_guard-core
201
+ - bin/bundle
70
202
  - bin/console
203
+ - bin/guard
204
+ - bin/rake
205
+ - bin/rspec
206
+ - bin/rubocop
71
207
  - bin/setup
208
+ - exe/todoplicator
72
209
  - lib/todoplicator.rb
73
- - lib/todoplicator/version.rb
210
+ - lib/todoplicator/adapter_registry.rb
211
+ - lib/todoplicator/find_adapter.rb
212
+ - lib/todoplicator/git_hub_adapter.rb
213
+ - lib/todoplicator/git_lab_adapter.rb
74
214
  - todoplicator.gemspec
75
215
  homepage:
76
216
  licenses:
@@ -1,3 +0,0 @@
1
- module Todoplicator
2
- VERSION = "0.0.1"
3
- end