knitter 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +15 -0
- data/knitter.gemspec +25 -28
- data/lib/knitter.rb +1 -1
- data/lib/knitter/package.rb +10 -26
- data/lib/knitter/version.rb +1 -1
- data/lib/knitter/{process.rb → yarn.rb} +33 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19b44d43ac679acb8157cde332e7d2c12a82b81b
|
4
|
+
data.tar.gz: b29c2b9b6c35493cf3388df228b98af39efd7166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f2a15ec0ac4c87f5f0a593fe7674019cced2d5531eb881ecf1fe81030162d1ac0c7804abbc5b42240330297169e8a2c41e9b6429cc1b6b385f347186517efe
|
7
|
+
data.tar.gz: e27568fdb0aefa36cbb2bf23994cdd57216fe90a2a75dc27c4ce6955996087965335095fe33af267b8854af4f23116005c9156de40524b80b029184d523bab39
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
StringLiterals:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/IndentationWidth:
|
5
|
+
# Number of spaces for each indentation level.
|
6
|
+
Width: 4
|
7
|
+
|
8
|
+
Style/EmptyLinesAroundClassBody:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/EmptyLinesAroundModuleBody:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/ClassAndModuleChildren:
|
15
|
+
Enabled: false
|
data/knitter.gemspec
CHANGED
@@ -4,38 +4,35 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'knitter/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
spec.name = "knitter"
|
8
|
+
spec.version = Knitter::VERSION
|
9
|
+
spec.authors = ["Nathan Stitt"]
|
10
|
+
spec.email = ["nathan@stitt.org"]
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = %q{Wraps the Javascript "yarn" package manager command}
|
13
|
+
spec.description = %q{Wraps the Javascript "yarn" command; query and install Javascript packages from Ruby. Reads the package.json file directly to detect packages that are installed, and shells out to `yarn` to initialize and install packages.}
|
14
|
+
spec.homepage = "https://github.com/nathanstitt/knitter"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
-
"public gem pushes."
|
24
|
-
end
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
f.match(%r{^(test|spec|features)/})
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
32
29
|
|
33
|
-
|
30
|
+
spec.add_dependency 'mixlib-shellout', '~> 2.2'
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "guard", "~> 2.13"
|
35
|
+
spec.add_development_dependency "spy", "~> 0.4.5"
|
36
|
+
spec.add_development_dependency "guard-minitest", "~> 2.3"
|
40
37
|
|
41
38
|
end
|
data/lib/knitter.rb
CHANGED
data/lib/knitter/package.rb
CHANGED
@@ -7,11 +7,11 @@ module Knitter
|
|
7
7
|
|
8
8
|
attr_reader :name, :dependency_type
|
9
9
|
|
10
|
-
attr_writer :
|
10
|
+
attr_writer :yarn
|
11
11
|
|
12
|
-
def initialize(name,
|
12
|
+
def initialize(name, yarn: nil)
|
13
13
|
@name = name
|
14
|
-
@
|
14
|
+
@yarn = yarn
|
15
15
|
end
|
16
16
|
|
17
17
|
def version
|
@@ -27,23 +27,15 @@ module Knitter
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def dependency_type
|
30
|
-
@dependency_type
|
31
|
-
case config.area
|
32
|
-
when 'optionalDependencies' then :optional
|
33
|
-
when 'devDependencies' then :development
|
34
|
-
when 'peerDependencies' then :peer
|
35
|
-
else
|
36
|
-
:dependencies
|
37
|
-
end
|
38
|
-
)
|
30
|
+
@dependency_type ||= Yarn::PACKAGE_AREAS.invert[config.area]
|
39
31
|
end
|
40
32
|
|
41
33
|
def installed?
|
42
|
-
!config.nil?
|
34
|
+
!config.area.nil?
|
43
35
|
end
|
44
36
|
|
45
37
|
def add
|
46
|
-
|
38
|
+
yarn.add(self)
|
47
39
|
@config = nil
|
48
40
|
end
|
49
41
|
|
@@ -51,25 +43,17 @@ module Knitter
|
|
51
43
|
@config ||= read_config
|
52
44
|
end
|
53
45
|
|
54
|
-
def valid?
|
55
|
-
process.package_file.exist? && config
|
56
|
-
end
|
57
|
-
|
58
46
|
protected
|
59
47
|
|
60
|
-
def
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def process
|
65
|
-
@process ||= Process.new(Dir.pwd)
|
48
|
+
def yarn
|
49
|
+
@yarn ||= Yarn.new(Dir.pwd)
|
66
50
|
end
|
67
51
|
|
68
52
|
def read_config
|
69
53
|
config = PackageConfig.new
|
70
|
-
|
54
|
+
json = yarn.package_file_contents
|
71
55
|
%w{dependencies devDependencies optionalDependencies}.each do | part_name |
|
72
|
-
part =
|
56
|
+
part = json[part_name]
|
73
57
|
next unless part && (version = part[@name])
|
74
58
|
config.area = part_name
|
75
59
|
config.version = version
|
data/lib/knitter/version.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
require 'mixlib/shellout'
|
2
|
+
require 'forwardable'
|
2
3
|
|
3
4
|
module Knitter
|
4
|
-
class
|
5
|
-
|
5
|
+
class Yarn
|
6
|
+
|
7
|
+
PACKAGE_AREAS = {
|
8
|
+
dev: 'devDependencies',
|
9
|
+
peer: 'peerDependencies',
|
10
|
+
optional: 'optionalDependencies',
|
11
|
+
dependencies: 'dependencies'
|
12
|
+
}
|
13
|
+
|
14
|
+
extend ::Forwardable
|
6
15
|
def_delegators :@sh, :stderr, :stdout
|
7
16
|
|
8
17
|
attr_reader :directory
|
@@ -33,6 +42,28 @@ module Knitter
|
|
33
42
|
@directory.join "package.json"
|
34
43
|
end
|
35
44
|
|
45
|
+
def packages
|
46
|
+
json = package_file_contents
|
47
|
+
Enumerator.new do | enum |
|
48
|
+
PACKAGE_AREAS.each do | type, area |
|
49
|
+
(json[area] || []).each do | package, version |
|
50
|
+
package = Package.new(package, yarn: self)
|
51
|
+
package.version = version
|
52
|
+
package.dependency_type = type
|
53
|
+
enum << package
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def package_file_contents
|
60
|
+
JSON.parse(package_file.read)
|
61
|
+
end
|
62
|
+
|
63
|
+
def valid?
|
64
|
+
package_file_contents
|
65
|
+
end
|
66
|
+
|
36
67
|
protected
|
37
68
|
|
38
69
|
def package_save_as_flag(package)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Stitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -104,6 +104,7 @@ extensions: []
|
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
106
|
- ".gitignore"
|
107
|
+
- ".rubocop.yml"
|
107
108
|
- Gemfile
|
108
109
|
- Guardfile
|
109
110
|
- LICENSE.txt
|
@@ -115,8 +116,8 @@ files:
|
|
115
116
|
- lib/knitter.rb
|
116
117
|
- lib/knitter/package.rb
|
117
118
|
- lib/knitter/package_version.rb
|
118
|
-
- lib/knitter/process.rb
|
119
119
|
- lib/knitter/version.rb
|
120
|
+
- lib/knitter/yarn.rb
|
120
121
|
- lib/yarn/wrapper.rb
|
121
122
|
- lib/yarn/wrapper/version.rb
|
122
123
|
homepage: https://github.com/nathanstitt/knitter
|