label 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6cf01f17f6dfd3998588bb648512af9cfcf416a
4
+ data.tar.gz: 555966948a51a9e8dcdba72aba1b0c7bc76b37df
5
+ SHA512:
6
+ metadata.gz: f51ead279688c2374b76c6a12064223946cf009b23b09636377285027de3efbaf46e3e0eee799afa5991b58dc9a00ba363d853afc522a3fb8991f2c51197fb55
7
+ data.tar.gz: b64196c0b500ed673b0d781394228e2fc4d9fd1b52883225e123d69bf328acad37ffdf24984b1da5fdd74cf9cb2ec11c5d87beb699ffc44c6d0efc4546cce2b0
data/lib/label/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Label
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/label.rb CHANGED
@@ -8,15 +8,24 @@ module Label
8
8
  class << self
9
9
 
10
10
  def label
11
- output = process "Gemfile"
11
+ describing = lambda { |gem| STDOUT.write "#{gem}: " }
12
+ described = lambda { |description| STDOUT.puts description }
12
13
 
13
- write "Gemfile", output
14
+ gemfile = "Gemfile"
15
+
16
+ output = process gemfile, describing, described
17
+
18
+ write gemfile, output
14
19
  end
15
20
 
16
21
  # Process the given Gemfile.
17
22
  #
18
- # gemfile - A String describing the path to a Gemfile.
19
- def process gemfile
23
+ # gemfile - A String describing the path to a Gemfile.
24
+ # describing - A Proc to be called once a query to describe a gem begins.
25
+ # Receives the name of the gem as an argument.
26
+ # described - A Proc to be called once a query to describe a gem completes.
27
+ # Receives the description as an argument.
28
+ def process gemfile, describing = nil, described = nil
20
29
  file = read gemfile
21
30
 
22
31
  lines = file.read.split "\n"
@@ -32,8 +41,14 @@ module Label
32
41
  whitespace = matches[1]
33
42
  gem = matches[2]
34
43
 
35
- unless previous_line.start_with? "#"
36
- processed_lines << "#{whitespace}# #{describe gem}"
44
+ unless previous_line =~ /^ *#/
45
+ describing.call gem if describing
46
+
47
+ description = describe gem
48
+
49
+ described.call description if described
50
+
51
+ processed_lines << "#{whitespace}# #{description}"
37
52
  end
38
53
  end
39
54
 
@@ -12,4 +12,6 @@ gem 'carrierwave'
12
12
  group :test do
13
13
  # BDD for Ruby
14
14
  gem 'rspec'
15
+ # Guard is a command line tool to easily handle events on file system modifications.
16
+ gem 'guard'
15
17
  end
@@ -10,4 +10,6 @@ gem 'carrierwave'
10
10
 
11
11
  group :test do
12
12
  gem 'rspec'
13
+ # Guard is a command line tool to easily handle events on file system modifications.
14
+ gem 'guard'
13
15
  end
data/spec/label_spec.rb CHANGED
@@ -3,11 +3,11 @@ require "spec_helper"
3
3
  describe Label do
4
4
  describe "#process" do
5
5
  it "should label unlabelled gems" do
6
- expect(File).to receive(:open).with("Gemfile").and_return(StringIO.new fixture("stock_gemfile"))
6
+ allow(File).to receive(:open).with("Gemfile").and_return(StringIO.new fixture("stock_gemfile"))
7
7
 
8
- expect(subject).to receive(:describe).with("rspec").and_return("BDD for Ruby")
8
+ allow(subject).to receive(:describe).with("rspec").and_return("BDD for Ruby")
9
9
 
10
- expect(subject).to receive(:describe).with("carrierwave").and_return(
10
+ allow(subject).to receive(:describe).with("carrierwave").and_return(
11
11
  "Upload files in your Ruby applications, map them to a range of ORMs, " +
12
12
  "store them on different backends."
13
13
  )
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: label
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Johannes Gorset
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-30 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: gems
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,33 +41,29 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Labels gems in your Gemfile
@@ -99,33 +90,26 @@ files:
99
90
  homepage: https://github.com/jgorset/label
100
91
  licenses:
101
92
  - MIT
93
+ metadata: {}
102
94
  post_install_message:
103
95
  rdoc_options: []
104
96
  require_paths:
105
97
  - lib
106
98
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
99
  requirements:
109
- - - ! '>='
100
+ - - '>='
110
101
  - !ruby/object:Gem::Version
111
102
  version: '0'
112
- segments:
113
- - 0
114
- hash: 363269059359041732
115
103
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
104
  requirements:
118
- - - ! '>='
105
+ - - '>='
119
106
  - !ruby/object:Gem::Version
120
107
  version: '0'
121
- segments:
122
- - 0
123
- hash: 363269059359041732
124
108
  requirements: []
125
109
  rubyforge_project:
126
- rubygems_version: 1.8.23
110
+ rubygems_version: 2.0.2
127
111
  signing_key:
128
- specification_version: 3
112
+ specification_version: 4
129
113
  summary: Label labels the gems in your Gemfile
130
114
  test_files:
131
115
  - spec/fixtures/processed_gemfile