gemius 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
  SHA1:
3
- metadata.gz: 9e59990d6ca437f24c46c6afe207d06158fcfddc
4
- data.tar.gz: da12cf9dd0a8b355ee2739c5c3a42560ea6bd7d4
3
+ metadata.gz: f0a7db136857444420f38d99e518a7f710ea480c
4
+ data.tar.gz: cae82d781f94a9b9e548b1edb4827507f5cbd537
5
5
  SHA512:
6
- metadata.gz: 89fc16549b8160179bd8ed37709695d7b0cc066408b37cc46b76f5b217221e826e51c2e55ff0731e46f4224ce37edad54c9920298e76d802d9b6bad567265b2d
7
- data.tar.gz: a746ee2ffafe2281510f017a6978c1c3c70af7b5b6b462c6797008663234fbb48e7b95e2de7af8f40ebdcacdaf01c46a596fde6e01dafdfd93024562f23889f8
6
+ metadata.gz: e65dff24442cf8d92683c17cd266617fcbdce90689cf117320bc73df0e46e624413350e23616c25eacadc02673083f4fab9708d173ca6e89dd1654eb8a9d4556
7
+ data.tar.gz: e419dc1ea82f947ab93a433a6e3c0b194dec27c042c072378b5a965253e6f08fbe433f49de8be483485fa73c34d6096a74d89273ed078be853e1ecb87300d313
data/README.md CHANGED
@@ -21,13 +21,15 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```ruby
24
- gemfile_lock = Gemius.gemfile_lock('path to Gemfile.lock')
25
-
26
- gemfile_lock.specs.first.name
27
- => "aws-s3"
28
-
29
- gemfile_lock.specs.first.version
30
- => "0.6.3"
24
+ gemfile_lock = Gemius.gemfile_lock('path to Gemfile.lock or its contents')
25
+
26
+ spec = gemfile_lock.specs.first
27
+ => {
28
+ name: "aws-s3",
29
+ version: "0.6.3",
30
+ remote: "git://github.com/JeremyGeros/aws-s3.git",
31
+ revision: "bdf58c51f55bb16a7f2a83f01c34976333cc5f4c"
32
+ }
31
33
  ```
32
34
 
33
35
  ## Development
@@ -39,4 +41,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
39
41
  ## Contributing
40
42
 
41
43
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gemius.
42
-
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", "~> 1.10"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "pry"
31
32
  end
@@ -2,7 +2,11 @@ require "gemius/version"
2
2
  require "gemius/gemfile_lock"
3
3
 
4
4
  module Gemius
5
- def self.gemfile_lock(filename)
6
- GemfileLock.new(File.read filename)
5
+ def self.gemfile_lock(path_or_content)
6
+ if File.file?(path_or_content)
7
+ GemfileLock.new(File.read path_or_content)
8
+ else
9
+ GemfileLock.new(path_or_content)
10
+ end
7
11
  end
8
12
  end
@@ -1,8 +1,8 @@
1
1
  module Gemius
2
2
  class GemfileLock
3
- SPEC_PATTERN = /^\s*([\w-]+)\s{1}\(((\d|\.)+)\)/
4
- GIT_SECTION_PATTERN = /^GIT\n\s+remote:\s(.+)\n\s+revision:\s(.*)\n\s+specs:\s((.|\n)*)/
5
- GEM_SECTION_PATTERN = /^GEM\n((.|\n)*)/
3
+ SPECS_SECTION_RE = /(?:\s{4}((?:\w|-|\.)+)\s\(((?:\w|\.)+)\))+\n?/
4
+ GIT_SECTION_RE = /\s{2}remote:\s(.+)\n\s{2}revision:\s(.+)\n(?:\s{2}ref:\s(.+))?\n?(?:\s{2}branch:\s(.+))?\n?(?:\s{2}tag:\s(.+))?/
5
+ REMOTE_RE = /\s{2}remote:\s(.+)/
6
6
 
7
7
  def initialize(file_content)
8
8
  @file_content = file_content
@@ -16,36 +16,38 @@ module Gemius
16
16
 
17
17
  attr_reader :file_content
18
18
 
19
- Spec = Struct.new :name, :version, :remote, :revision
20
-
21
19
  def parse_section(section)
22
- if section.start_with?("GIT\n")
20
+ if section.start_with?("GIT")
23
21
  parse_git_section(section)
24
- elsif section.start_with?('GEM')
22
+ elsif section.start_with?("PATH")
23
+ parse_path_section(section)
24
+ elsif section.start_with?("GEM")
25
25
  parse_gem_section(section)
26
26
  end
27
27
  end
28
28
 
29
- def parse_spec_section(content, remote = nil, revision = nil)
30
- content.split("\n").map { |line| parse_spec(line, remote, revision) }.compact
31
- end
32
-
33
- def parse_spec(line, remote = nil, revision = nil)
34
- _, name, version = line.match(SPEC_PATTERN).to_a
29
+ def parse_git_section(section)
30
+ _, remote, revision, ref, branch, tag = section.match(GIT_SECTION_RE).to_a
31
+ additional_props = {remote: remote, revision: revision}
32
+ additional_props[:ref] = ref if ref
33
+ additional_props[:branch] = branch if branch
34
+ additional_props[:tag] = tag if tag
35
35
 
36
- Spec.new(name, version, remote, revision) if name && version
36
+ parse_specs_section(section, additional_props)
37
37
  end
38
38
 
39
- def parse_git_section(content)
40
- _, remote, revision, specs_section = content.match(GIT_SECTION_PATTERN).to_a
41
-
42
- parse_spec_section(specs_section, remote, revision) if specs_section
39
+ def parse_path_section(section)
40
+ parse_specs_section(section, remote: section.match(REMOTE_RE)[1])
43
41
  end
44
42
 
45
- def parse_gem_section(content)
46
- _, specs_section = content.match(GEM_SECTION_PATTERN).to_a
43
+ def parse_gem_section(section)
44
+ parse_specs_section(section, remote: section.scan(REMOTE_RE).flatten.join(", "))
45
+ end
47
46
 
48
- parse_spec_section(specs_section) if specs_section
47
+ def parse_specs_section(section, additional_props)
48
+ section.scan(SPECS_SECTION_RE).map do |(name, version)|
49
+ {name: name, version: version}.merge!(additional_props)
50
+ end
49
51
  end
50
52
  end
51
- end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Gemius
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemius
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
  - Konstantin Lazarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ version_requirements: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '1.10'
19
+ name: bundler
14
20
  requirement: !ruby/object:Gem::Requirement
15
21
  requirements:
16
22
  - - ~>
17
23
  - !ruby/object:Gem::Version
18
24
  version: '1.10'
19
25
  type: :development
20
- name: bundler
21
26
  prerelease: false
27
+ - !ruby/object:Gem::Dependency
22
28
  version_requirements: !ruby/object:Gem::Requirement
23
29
  requirements:
24
30
  - - ~>
25
31
  - !ruby/object:Gem::Version
26
- version: '1.10'
27
- - !ruby/object:Gem::Dependency
32
+ version: '10.0'
33
+ name: rake
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - ~>
31
37
  - !ruby/object:Gem::Version
32
38
  version: '10.0'
33
39
  type: :development
34
- name: rake
35
40
  prerelease: false
41
+ - !ruby/object:Gem::Dependency
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - '>='
39
45
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
46
+ version: '0'
47
+ name: rspec
42
48
  requirement: !ruby/object:Gem::Requirement
43
49
  requirements:
44
50
  - - '>='
45
51
  - !ruby/object:Gem::Version
46
52
  version: '0'
47
53
  type: :development
48
- name: rspec
49
54
  prerelease: false
55
+ - !ruby/object:Gem::Dependency
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - '>='
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
61
+ name: pry
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
55
69
  description:
56
70
  email:
57
71
  - le6oww5k1@gmail.com