skippy 0.4.1.a → 0.4.2.a

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: ce2b2452959a54d094d90bac57789f3738137f7d94ce844db4a6a2b08788925d
4
- data.tar.gz: f3984931967ac74cfb3d5c8c233855385e0bee8c046d4d8156c0fec1d503d320
2
+ SHA1:
3
+ metadata.gz: 7fb507a519db6a67ab099f00097e2d631a7d1adf
4
+ data.tar.gz: b8a6cea5346d7ed5bc3d699ecd9cedd98563e355
5
5
  SHA512:
6
- metadata.gz: b18020a84524b9d4842e22939ada7fdf9f1edec500a4dce6d9ff6642ef47d335c46debb5c7933a4e504c191eb953af5a4654977787b9ce6e1734e408c1019f7f
7
- data.tar.gz: 1836e67a3a1a547b3f7f9caa96d729157246621df36045171920e234eeccc9224419730a53dddf6d17a603b6d1871135d2ad1dcd99472fd34dbc833c4d3f19a3
6
+ metadata.gz: 2ae139c5630b471b4be7366321d8615fea6b367dd5e1f1133f0ec914b25f0d97b8138318e3fb11189263668a8d75f6b92467b8336e42328b7f477ab67a1e90db
7
+ data.tar.gz: ce10a2212bb23fea1eccf02bf18ecd6fbe35619f49ac630d1afe47fdd21dafdf1ca0dd1004c1c71b0b4d73031701b63c9223f1952c1ea4a86beff2bcb28b14d4
@@ -9,6 +9,7 @@ AllCops:
9
9
  - 'vendor/**/*'
10
10
  DisplayCopNames: true
11
11
 
12
+
12
13
  Layout/AlignParameters:
13
14
  EnforcedStyle: with_fixed_indentation
14
15
 
@@ -36,6 +37,11 @@ Layout/EndOfLine:
36
37
  Layout/EmptyLinesAroundBlockBody:
37
38
  Enabled: false
38
39
 
40
+
41
+ Naming/RescuedExceptionsVariableName:
42
+ PreferredName: error
43
+
44
+
39
45
  Metrics/AbcSize:
40
46
  Enabled: false
41
47
  Exclude:
@@ -61,6 +67,7 @@ Metrics/MethodLength:
61
67
  Metrics/PerceivedComplexity:
62
68
  Enabled: false
63
69
 
70
+
64
71
  # Prefer { ... } over do ... end except for control flow and
65
72
  # method defintions. Unfortunatly, no cop configuration for this.
66
73
  # https://github.com/chneukirchen/styleguide/blob/e60de37b478d3f892f6985a58d573016f33f0269/RUBY-STYLE#L63-L67
@@ -109,5 +116,8 @@ Style/SymbolArray:
109
116
  Enabled: False
110
117
 
111
118
  # Add trailing comma so it's easy to duplicate/add lines.
112
- Style/TrailingCommaInLiteral:
119
+ Style/TrailingCommaInArrayLiteral:
120
+ EnforcedStyleForMultiline: consistent_comma
121
+
122
+ Style/TrailingCommaInHashLiteral:
113
123
  EnforcedStyleForMultiline: consistent_comma
@@ -1,18 +1,18 @@
1
- {
2
- // See https://go.microsoft.com/fwlink/?LinkId=733558
3
- // for the documentation about the tasks.json format
4
- "version": "2.0.0",
5
- "tasks": [
6
- {
7
- "label": "rake test FILE",
8
- "type": "shell",
9
- "command": "bundle",
10
- "args": [
11
- "exec",
12
- "rake",
13
- "TEST=${relativeFile}"
14
- ],
15
- "group": "test"
16
- }
17
- ]
18
- }
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+ // for the documentation about the tasks.json format
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "label": "rake test FILE",
8
+ "type": "shell",
9
+ "command": "bundle",
10
+ "args": [
11
+ "exec",
12
+ "rake",
13
+ "TEST=${relativeFile}"
14
+ ],
15
+ "group": "test"
16
+ }
17
+ ]
18
+ }
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :development do
13
13
  # gem 'aruba', git: 'https://github.com/rbld/aruba.git',
14
14
  # branch: 'aruba-win-fix'
15
15
  gem 'pry'
16
- gem 'rubocop', '~> 0.51.0', require: false
16
+ gem 'rubocop', '~> 0.67.2', require: false
17
+ gem 'rubocop-performance', '~> 1.1.0', require: false
17
18
  gem 'webmock', '~> 3.1'
18
19
  end
data/Rakefile CHANGED
@@ -5,6 +5,9 @@ Rake::TestTask.new(:test) do |t|
5
5
  t.libs << 'test'
6
6
  t.libs << 'lib'
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
+ # Turning off because Rake 11 >= turns warning on by default.
9
+ # TODO: Clean up the warnings coming from this project and enable.
10
+ t.warning = false
8
11
  end
9
12
 
10
13
  task default: :test
@@ -38,6 +38,7 @@ class New < Skippy::Command::Group
38
38
  if project.exist?
39
39
  raise Skippy::Error, "A project already exist: #{project.filename}"
40
40
  end
41
+
41
42
  project.namespace = namespace
42
43
  project.name = project.namespace.to_name
43
44
  project.basename = options[:basename] || project.namespace.short_name
@@ -15,6 +15,7 @@ class Sketchup < Skippy::Command
15
15
  unless app.can_debug
16
16
  raise Skippy::Error, "Debug library not installed for Sketchup #{version}"
17
17
  end
18
+
18
19
  arguments = ['-rdebug', %("ide port=#{options.port}")]
19
20
  Skippy.os.launch_app(app.executable, *arguments)
20
21
  end
@@ -51,10 +52,14 @@ class Sketchup < Skippy::Command
51
52
  # @param [Integer] version
52
53
  # @return [Skippy::SketchUpApp, nil]
53
54
  def find_sketchup(version)
55
+ # Allow shortcuts such as 18 to mean 2018.
56
+ full_version = version.to_i
57
+ full_version += 2000 if (13..99).cover?(full_version)
54
58
  app = Skippy.os.sketchup_apps.find { |sketchup|
55
- sketchup.version == version.to_i
59
+ sketchup.version == full_version
56
60
  }
57
61
  raise Skippy::Error, "SketchUp #{version} not found." if app.nil?
62
+
58
63
  app
59
64
  end
60
65
 
@@ -43,6 +43,7 @@ class Skippy::App
43
43
  template_path = templates_source_path.join(entry)
44
44
  next unless template_path.directory?
45
45
  next if %w(. ..).include?(entry.basename.to_s)
46
+
46
47
  result << entry.expand_path(templates_source_path)
47
48
  }
48
49
  result
@@ -57,11 +57,12 @@ class Skippy::CLI < Skippy::Command
57
57
  end
58
58
  end
59
59
 
60
+ # rubocop:disable Style/MethodMissingSuper,Style/MissingRespondToMissing
60
61
  # Verbatim copy from Thor::Runner:
61
62
  # If a command is not found on Thor::Runner, method missing is invoked and
62
63
  # Thor::Runner is then responsible for finding the command in all classes.
63
64
  #
64
- def method_missing(meth, *args) # rubocop:disable Style/MethodMissing
65
+ def method_missing(meth, *args)
65
66
  meth = meth.to_s
66
67
  initialize_thorfiles(meth)
67
68
  klass, command = Thor::Util.find_class_and_command_by_namespace(meth)
@@ -69,14 +70,15 @@ class Skippy::CLI < Skippy::Command
69
70
  args.unshift(command) if command
70
71
  klass.start(args, shell: shell)
71
72
  end
73
+ # rubocop:enable Style/MethodMissingSuper,Style/MissingRespondToMissing
72
74
 
73
75
  # Verbatim copy from Thor::Runner:
74
76
  desc 'list [SEARCH]',
75
77
  "List the available #{$PROGRAM_NAME} commands (--substring means .*SEARCH)"
76
78
  method_options substring: :boolean,
77
- group: :string,
78
- all: :boolean,
79
- debug: :boolean
79
+ group: :string,
80
+ all: :boolean,
81
+ debug: :boolean
80
82
  def list(search = '')
81
83
  initialize_thorfiles
82
84
 
@@ -112,8 +114,9 @@ class Skippy::CLI < Skippy::Command
112
114
  def initialize_thorfiles(_relevant_to = nil, _skip_lookup = false)
113
115
  project = Skippy::Project.new(Dir.pwd)
114
116
  return unless project.exist?
117
+
115
118
  project.command_files { |filename|
116
- unless Thor::Base.subclass_files.keys.include?(File.expand_path(filename))
119
+ unless Thor::Base.subclass_files.key?(File.expand_path(filename))
117
120
  begin
118
121
  Thor::Util.load_thorfile(filename, nil, options[:debug])
119
122
  rescue ScriptError, StandardError => error
@@ -35,6 +35,7 @@ class Skippy::Config < Hash
35
35
  item = get_item(key_path)
36
36
  item = set_item(key_path, []) if item.nil?
37
37
  raise ArgumentError, 'key path is not an Array' unless item.is_a?(Array)
38
+
38
39
  item << value
39
40
  end
40
41
 
@@ -52,6 +53,7 @@ class Skippy::Config < Hash
52
53
 
53
54
  def save
54
55
  raise MissingPathError if path.nil?
56
+
55
57
  export(path)
56
58
  end
57
59
 
@@ -117,9 +119,11 @@ class Skippy::Config < Hash
117
119
  def get_item(key_path)
118
120
  parts = key_parts(key_path)
119
121
  return nil if parts.empty?
122
+
120
123
  item = self
121
124
  parts.each { |key|
122
125
  return nil if item.nil?
126
+
123
127
  item = item[key]
124
128
  }
125
129
  item
@@ -15,6 +15,7 @@ module Skippy::ConfigAccessors
15
15
  class_eval do
16
16
  symbols.each { |symbol|
17
17
  raise TypeError unless symbol.is_a?(Symbol)
18
+
18
19
  define_method(symbol) do
19
20
  value = @config.get(key || symbol, default)
20
21
  value = type.new(value) if type && !value.is_a?(type)
@@ -29,6 +30,7 @@ module Skippy::ConfigAccessors
29
30
  class_eval do
30
31
  symbols.each { |symbol|
31
32
  raise TypeError unless symbol.is_a?(Symbol)
33
+
32
34
  symbol_set = "#{symbol}=".intern
33
35
  define_method(symbol_set) do |value|
34
36
  value = type.new(value) if type && !value.is_a?(type)
@@ -7,6 +7,7 @@ module Skippy::Helpers
7
7
  # @return [Array<Pathname>]
8
8
  def directories(pathname)
9
9
  return [] unless pathname.exist?
10
+
10
11
  pathname.children.select(&:directory?)
11
12
  end
12
13
 
@@ -27,7 +27,7 @@ class Skippy::GitLibraryInstaller < Skippy::LibraryInstaller
27
27
  end
28
28
  begin
29
29
  checkout_branch(git, source.branch) if source.branch
30
- checkout_tag(git, source.requirement) unless edge_version?(source.requirement)
30
+ checkout_tag(git, source.requirement) unless edge_version?(source.requirement) # rubocop:disable Metrics/LineLength
31
31
  rescue Skippy::Error
32
32
  git.checkout(previous_commit) if previous_commit
33
33
  raise
@@ -67,6 +67,7 @@ class Skippy::GitLibraryInstaller < Skippy::LibraryInstaller
67
67
  unless branches.include?(branch)
68
68
  raise Skippy::BranchNotFound, "Found no branch named: '#{branch}'"
69
69
  end
70
+
70
71
  git.checkout(branch)
71
72
  nil
72
73
  end
@@ -77,6 +78,7 @@ class Skippy::GitLibraryInstaller < Skippy::LibraryInstaller
77
78
  tags = Naturally.sort_by(git.tags, :name)
78
79
  tag = latest_version?(version) ? tags.last : resolve_tag(tags, version)
79
80
  raise Skippy::TagNotFound, "Found no version: '#{version}'" if tag.nil?
81
+
80
82
  git.checkout(tag)
81
83
  # Verify the library version with the tagged version.
82
84
  target = path.join(source.lib_path)
@@ -97,6 +99,7 @@ class Skippy::GitLibraryInstaller < Skippy::LibraryInstaller
97
99
  requirement = Gem::Requirement.new(version)
98
100
  tags.reverse.find { |tag|
99
101
  next false unless Gem::Version.correct?(tag.name)
102
+
100
103
  tag_version = Gem::Version.new(tag.name)
101
104
  requirement.satisfied_by?(tag_version)
102
105
  }
@@ -13,6 +13,7 @@ class Skippy::LibModule
13
13
  def initialize(library, path)
14
14
  @path = Pathname.new(path)
15
15
  raise ModuleNotFoundError, @path.to_s unless @path.file?
16
+
16
17
  @library = library
17
18
  end
18
19
 
@@ -40,6 +40,7 @@ class Skippy::LibrarySource
40
40
  # @return [String, nil]
41
41
  def requirement
42
42
  return nil if @options[:requirement].nil?
43
+
43
44
  # Normalize the version requirement pattern.
44
45
  parts = Gem::Requirement.parse(@options[:requirement])
45
46
  # .parse will from '1.2.3' return ['=', '1.2.3']. Don't need that.
@@ -28,8 +28,10 @@ class Skippy::Library
28
28
  @path = Pathname.new(path)
29
29
  raise LibraryNotFoundError, @path.to_s unless @path.directory?
30
30
  raise LibraryNotFoundError, config_file.to_s unless config_file.exist?
31
+
31
32
  @config = Skippy::Config.load(config_file)
32
33
  raise LibraryNotFoundError, 'Not a Skippy Library' unless @config[:library]
34
+
33
35
  @source = source
34
36
  end
35
37
 
@@ -29,6 +29,7 @@ class Skippy::LibraryManager
29
29
  # @param [Skippy::Project] project
30
30
  def initialize(project)
31
31
  raise TypeError, 'expected a Project' unless project.is_a?(Skippy::Project)
32
+
32
33
  @project = project
33
34
  @libraries = SortedSet.new(discover_libraries)
34
35
  end
@@ -56,8 +57,10 @@ class Skippy::LibraryManager
56
57
  if library_name.nil? || module_name.nil?
57
58
  raise ArgumentError, 'expected a module path'
58
59
  end
60
+
59
61
  library = find_library(library_name)
60
62
  return nil if library.nil?
63
+
61
64
  library.modules.find { |mod| mod.basename.casecmp(module_name).zero? }
62
65
  end
63
66
 
@@ -77,6 +80,7 @@ class Skippy::LibraryManager
77
80
  # @return [Skippy::Library]
78
81
  def install(source, options = {})
79
82
  raise Skippy::Project::ProjectNotSavedError unless project.exist?
83
+
80
84
  lib_source = Skippy::LibrarySource.new(project, source, options)
81
85
 
82
86
  installer = get_installer(lib_source)
@@ -99,8 +103,10 @@ class Skippy::LibraryManager
99
103
  # @return [Skippy::Library]
100
104
  def uninstall(lib)
101
105
  raise Skippy::Project::ProjectNotSavedError unless project.exist?
106
+
102
107
  library = lib.is_a?(Skippy::Library) ? lib : find_library(lib)
103
108
  raise Skippy::LibraryNotFound, 'Library not found' if library.nil?
109
+
104
110
  # Uninstall modules first - using the module manager.
105
111
  vendor_path = project.modules.vendor_path
106
112
  vendor_module_path = vendor_path.join(library.name)
@@ -113,9 +119,11 @@ class Skippy::LibraryManager
113
119
  vendor_path.rmdir
114
120
  end
115
121
  raise 'Unable to remove vendor modules' if vendor_module_path.exist?
122
+
116
123
  # Now the library itself is safe to remove.
117
124
  library.path.rmtree if library.path.exist?
118
125
  raise 'Unable to remove library' if library.path.exist?
126
+
119
127
  @libraries.delete(library)
120
128
  library
121
129
  end
@@ -17,6 +17,7 @@ class Skippy::ModuleManager
17
17
  # @param [Skippy::Project] project
18
18
  def initialize(project)
19
19
  raise TypeError, 'expected a Project' unless project.is_a?(Skippy::Project)
20
+
20
21
  @project = project
21
22
  @modules = SortedSet.new(discover_modules)
22
23
  end
@@ -48,6 +49,7 @@ class Skippy::ModuleManager
48
49
  # @return [Skippy::LibModule]
49
50
  def use(module_name)
50
51
  raise Skippy::Project::ProjectNotSavedError unless project.exist?
52
+
51
53
  lib_module = project.libraries.find_module_or_fail(module_name)
52
54
 
53
55
  source = lib_module.path
@@ -63,6 +65,7 @@ class Skippy::ModuleManager
63
65
  # @return [Array<Skippy::LibModule>]
64
66
  def update(library)
65
67
  raise Skippy::Project::ProjectNotSavedError unless project.exist?
68
+
66
69
  installed = select { |mod| mod.library.name.casecmp(library.name).zero? }
67
70
  installed.each { |mod| use(mod.name) }
68
71
  installed
@@ -72,6 +75,7 @@ class Skippy::ModuleManager
72
75
  # @return [Skippy::LibModule]
73
76
  def remove(module_name)
74
77
  raise Skippy::Project::ProjectNotSavedError unless project.exist?
78
+
75
79
  lib_module = project.libraries.find_module_or_fail(module_name)
76
80
 
77
81
  target = vendor_path.join(lib_module.library.name, lib_module.path.basename)
@@ -103,9 +107,11 @@ class Skippy::ModuleManager
103
107
  project.libraries.each { |library|
104
108
  library_vendor_path = vendor_path.join(library.name)
105
109
  next unless library_vendor_path.directory?
110
+
106
111
  library_vendor_path.each_child { |module_file|
107
112
  next unless module_file.file?
108
113
  next unless module_file.extname.casecmp('.rb').zero?
114
+
109
115
  modules << Skippy::LibModule.new(library, module_file)
110
116
  }
111
117
  }
@@ -122,6 +128,7 @@ class Skippy::ModuleManager
122
128
  basename = source.basename('.*')
123
129
  source_support_folder = source.parent.join(basename)
124
130
  return unless source_support_folder.directory?
131
+
125
132
  target_support_folder = target.parent.join(basename)
126
133
  copy_directory(lib_module, source_support_folder, target_support_folder)
127
134
  end
@@ -133,6 +140,7 @@ class Skippy::ModuleManager
133
140
  Dir.glob("#{source_path}/**/*") { |filename|
134
141
  source = Pathname.new(filename)
135
142
  next unless source.file?
143
+
136
144
  relative_path = source.relative_path_from(source_path)
137
145
  target = target_path.join(relative_path)
138
146
  copy_file(lib_module, source, target)
@@ -164,7 +172,7 @@ class Skippy::ModuleManager
164
172
  content
165
173
  end
166
174
 
167
- LIB_REQUIRE_PATTERN = %r{(\brequire ["'])(modules)(/[^"']*["'])}
175
+ LIB_REQUIRE_PATTERN = %r{(\brequire ["'])(modules)(/[^"']*["'])}.freeze
168
176
 
169
177
  # Transform the require statements to the target destination.
170
178
  #
@@ -6,6 +6,7 @@ class Skippy::Namespace
6
6
  unless valid?(namespace)
7
7
  raise Skippy::Error, "'#{namespace}' is not a valid Ruby namespace"
8
8
  end
9
+
9
10
  @namespace = namespace
10
11
  end
11
12
 
@@ -24,6 +25,7 @@ class Skippy::Namespace
24
25
  def short_name
25
26
  items = to_a
26
27
  return to_s unless items.size > 1
28
+
27
29
  initials = items.first.scan(/[[:upper:]]/)
28
30
  prefix = initials.size > 1 ? initials.join : items.first[0, 2]
29
31
  "#{prefix}_#{items.last}"
@@ -36,6 +36,7 @@ class Skippy::Project
36
36
  def self.current_or_fail
37
37
  project = current
38
38
  raise ProjectNotFoundError, project.filename unless project.exist?
39
+
39
40
  project
40
41
  end
41
42
 
@@ -108,8 +109,8 @@ class Skippy::Project
108
109
  end
109
110
 
110
111
  # @return [String]
111
- def to_json
112
- JSON.pretty_generate(@config)
112
+ def to_json(*args)
113
+ JSON.pretty_generate(@config, *args)
113
114
  end
114
115
 
115
116
  private
@@ -141,6 +142,7 @@ class Skippy::Project
141
142
  project_file = pathname.join(PROJECT_FILENAME)
142
143
  return pathname if project_file.exist?
143
144
  break if pathname.root?
145
+
144
146
  pathname = pathname.parent
145
147
  end
146
148
  nil
@@ -1,5 +1,5 @@
1
1
  module Skippy
2
2
 
3
- VERSION = '0.4.1.a'.freeze
3
+ VERSION = '0.4.2.a'.freeze
4
4
 
5
5
  end
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'naturally', '~> 2.1'
29
29
  spec.add_dependency 'thor', '~> 0.19'
30
30
 
31
- spec.add_development_dependency 'bundler', '~> 1.13'
32
- spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'bundler', '>= 1.15.0', '< 3.0'
32
+ spec.add_development_dependency 'rake', '~> 12.3.3'
33
33
  spec.add_development_dependency 'minitest', '~> 5.0'
34
34
  # TODO(thomthom): Need to lock to 2.3 because 2.4 fails with the custom
35
35
  # aruba build.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1.a
4
+ version: 0.4.2.a
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Thomassen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-26 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -56,30 +56,36 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.15.0
62
+ - - "<"
60
63
  - !ruby/object:Gem::Version
61
- version: '1.13'
64
+ version: '3.0'
62
65
  type: :development
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.15.0
72
+ - - "<"
67
73
  - !ruby/object:Gem::Version
68
- version: '1.13'
74
+ version: '3.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '10.0'
81
+ version: 12.3.3
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '10.0'
88
+ version: 12.3.3
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: minitest
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -255,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
261
  version: 1.3.1
256
262
  requirements: []
257
263
  rubyforge_project:
258
- rubygems_version: 2.7.3
264
+ rubygems_version: 2.6.14
259
265
  signing_key:
260
266
  specification_version: 4
261
267
  summary: CLI development tool for SketchUp extensions.