label 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +23 -15
- data/bin/label +5 -0
- data/label.gemspec +4 -1
- data/lib/label.rb +67 -1
- data/lib/label/version.rb +1 -1
- data/spec/fixtures/forced_processed_gemfile +7 -0
- data/spec/fixtures/processed_gemfile +7 -0
- data/spec/fixtures/stock_gemfile +6 -0
- data/spec/label_spec.rb +19 -0
- data/spec/spec_helper.rb +5 -0
- metadata +50 -6
data/README.md
CHANGED
@@ -1,29 +1,37 @@
|
|
1
1
|
# Label
|
2
2
|
|
3
|
-
|
3
|
+
Label labels the gems in your Gemfile.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
$ gem install label
|
8
8
|
|
9
|
-
|
9
|
+
## Usage
|
10
10
|
|
11
|
-
|
11
|
+
$ cd /path/to/Gemfile
|
12
|
+
$ label
|
12
13
|
|
13
|
-
|
14
|
+
```ruby
|
15
|
+
# /path/to/Gemfile
|
14
16
|
|
15
|
-
|
17
|
+
source 'http://rubygems.org'
|
16
18
|
|
17
|
-
|
19
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
20
|
+
gem 'rails', '4.0.0'
|
18
21
|
|
19
|
-
|
22
|
+
# Flexible authentication solution for Rails with Warden
|
23
|
+
gem 'devise'
|
24
|
+
|
25
|
+
# Upload files in your Ruby applications, map them to a range of ORMs, store
|
26
|
+
# them on different backends.
|
27
|
+
gem 'carrierwave'
|
20
28
|
|
21
|
-
|
29
|
+
# RailsAdmin is a Rails engine that provides an easy-to-use interface for
|
30
|
+
# managing your data.
|
31
|
+
gem 'rails_admin'
|
32
|
+
```
|
22
33
|
|
23
|
-
##
|
34
|
+
## I love you
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
36
|
+
Johannes Gorset made this. You should [tweet me](http://twitter.com/jgorset) if you can't get
|
37
|
+
it to work. In fact, you should tweet me anyway.
|
data/bin/label
ADDED
data/label.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Johannes Gorset"]
|
10
10
|
spec.email = ["jgorset@gmail.com"]
|
11
11
|
spec.description = "Labels gems in your Gemfile"
|
12
|
-
spec.summary = "Label labels the gems in your
|
12
|
+
spec.summary = "Label labels the gems in your Gemfile"
|
13
13
|
spec.homepage = "https://github.com/jgorset/label"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,6 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "gems", "~> 0.8"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
23
26
|
end
|
data/lib/label.rb
CHANGED
@@ -1,5 +1,71 @@
|
|
1
1
|
require "label/version"
|
2
|
+
require "optparse"
|
3
|
+
require "ostruct"
|
4
|
+
require "gems"
|
2
5
|
|
3
6
|
module Label
|
4
|
-
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def label
|
11
|
+
output = process "Gemfile"
|
12
|
+
|
13
|
+
write "Gemfile", output
|
14
|
+
end
|
15
|
+
|
16
|
+
# Process the given Gemfile.
|
17
|
+
#
|
18
|
+
# gemfile - A String describing the path to a Gemfile.
|
19
|
+
def process gemfile
|
20
|
+
file = read gemfile
|
21
|
+
|
22
|
+
lines = file.read.split "\n"
|
23
|
+
|
24
|
+
processed_lines = []
|
25
|
+
|
26
|
+
lines.each_with_index do |line, i|
|
27
|
+
gem = line[/gem ['"](.+)['"]/, 1]
|
28
|
+
|
29
|
+
if gem
|
30
|
+
previous_line = lines[i - 1]
|
31
|
+
|
32
|
+
unless previous_line.start_with? "#"
|
33
|
+
processed_lines << "# #{describe gem}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
processed_lines << line
|
38
|
+
end
|
39
|
+
|
40
|
+
processed_lines.join("\n") + "\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Read the given file.
|
44
|
+
#
|
45
|
+
# file - A String describing the path to a file.
|
46
|
+
def read file
|
47
|
+
File.open file
|
48
|
+
end
|
49
|
+
|
50
|
+
# Write to the given file.
|
51
|
+
#
|
52
|
+
# file - A String describing the path to a file.
|
53
|
+
# text - A String describing text to be written.
|
54
|
+
def write file, text
|
55
|
+
File.open file, "w" do |file|
|
56
|
+
file.write text
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Describe the given gem.
|
61
|
+
#
|
62
|
+
# gem - A String describing the name of a gem.
|
63
|
+
#
|
64
|
+
# Returns a String.
|
65
|
+
def describe gem
|
66
|
+
Gems.info(gem).fetch "info"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
5
71
|
end
|
data/lib/label/version.rb
CHANGED
data/spec/label_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Label do
|
4
|
+
describe "#process" do
|
5
|
+
it "should label unlabelled gems" do
|
6
|
+
expect(File).to receive(:open).with("Gemfile").and_return(StringIO.new fixture("stock_gemfile"))
|
7
|
+
|
8
|
+
expect(subject.process("Gemfile")).to eq fixture("processed_gemfile")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#describe" do
|
13
|
+
it "should describe a given gem" do
|
14
|
+
expect(Gems).to receive(:info).with("label").and_return("info" => "Label gems in your Gemfile")
|
15
|
+
|
16
|
+
expect(subject.describe("label")).to eq "Label gems in your Gemfile"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: label
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,6 +11,22 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2013-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: gems
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.8'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.8'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: bundler
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,10 +59,27 @@ dependencies:
|
|
43
59
|
- - ! '>='
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
46
78
|
description: Labels gems in your Gemfile
|
47
79
|
email:
|
48
80
|
- jgorset@gmail.com
|
49
|
-
executables:
|
81
|
+
executables:
|
82
|
+
- label
|
50
83
|
extensions: []
|
51
84
|
extra_rdoc_files: []
|
52
85
|
files:
|
@@ -55,9 +88,15 @@ files:
|
|
55
88
|
- LICENSE.txt
|
56
89
|
- README.md
|
57
90
|
- Rakefile
|
91
|
+
- bin/label
|
58
92
|
- label.gemspec
|
59
93
|
- lib/label.rb
|
60
94
|
- lib/label/version.rb
|
95
|
+
- spec/fixtures/forced_processed_gemfile
|
96
|
+
- spec/fixtures/processed_gemfile
|
97
|
+
- spec/fixtures/stock_gemfile
|
98
|
+
- spec/label_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
61
100
|
homepage: https://github.com/jgorset/label
|
62
101
|
licenses:
|
63
102
|
- MIT
|
@@ -73,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
112
|
version: '0'
|
74
113
|
segments:
|
75
114
|
- 0
|
76
|
-
hash: -
|
115
|
+
hash: -1622466383723177347
|
77
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
117
|
none: false
|
79
118
|
requirements:
|
@@ -82,11 +121,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
121
|
version: '0'
|
83
122
|
segments:
|
84
123
|
- 0
|
85
|
-
hash: -
|
124
|
+
hash: -1622466383723177347
|
86
125
|
requirements: []
|
87
126
|
rubyforge_project:
|
88
127
|
rubygems_version: 1.8.23
|
89
128
|
signing_key:
|
90
129
|
specification_version: 3
|
91
|
-
summary: Label labels the gems in your
|
92
|
-
test_files:
|
130
|
+
summary: Label labels the gems in your Gemfile
|
131
|
+
test_files:
|
132
|
+
- spec/fixtures/forced_processed_gemfile
|
133
|
+
- spec/fixtures/processed_gemfile
|
134
|
+
- spec/fixtures/stock_gemfile
|
135
|
+
- spec/label_spec.rb
|
136
|
+
- spec/spec_helper.rb
|