rubygems-manifest 0.1.0

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: f8decea168668e4f67e9447df2673b21e3d827a4
4
+ data.tar.gz: 81d56949c87a93f5fd7567dc82a9d0feef3785a5
5
+ SHA512:
6
+ metadata.gz: 561a4f50f00baec00848de357d7c47dbeb0e1da107c9a581da6b17f3722e8e886cc7d3e28262b97dfde7845d0cb27ac42939e4f9f2c7c6dfd9981327539784c8
7
+ data.tar.gz: f6e1451b592658374b3979a9e93723176b7e09c430230938aad9f27345327b332dbc790deb21766d416fbb3fe503a02ebed88734a673f93e8d93eb51bb364050
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - jruby-19mode
5
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubygems-manifest.gemspec
4
+ gemspec
data/HISTORY.md ADDED
@@ -0,0 +1,5 @@
1
+ # HEAD
2
+
3
+ # 0.1.0
4
+
5
+ * Initial commit
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Wojciech Mach
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,17 @@
1
+ .gitignore
2
+ .travis.yml
3
+ Gemfile
4
+ HISTORY.md
5
+ LICENSE.txt
6
+ Manifest.txt
7
+ README.md
8
+ Rakefile
9
+ VERSION
10
+ bin/manifest
11
+ lib/rubygems/manifest.rb
12
+ lib/rubygems/manifest/cli.rb
13
+ lib/rubygems/manifest/version.rb
14
+ rubygems-manifest.gemspec
15
+ test/bin/manifest_test.rb
16
+ test/rubygems/manifest_test.rb
17
+ test/test_helper.rb
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Rubygems::Manifest
2
+
3
+ [![Build Status](https://secure.travis-ci.org/wojtekmach/rubygems-manifest.png?branch=master)](http://travis-ci.org/wojtekmach/rubygems-manifest)
4
+
5
+ Create Manifest.txt with the list of files of the current project
6
+
7
+ ## Installation
8
+
9
+ $ gem install rubygems-manifest
10
+
11
+ ## Usage
12
+
13
+ Start a new project:
14
+
15
+ $ mkdir example ; cd example
16
+ $ touch a.txt
17
+ $ manifest
18
+ >> Manifest is empty
19
+
20
+ Save manifest:
21
+
22
+ $ git add .
23
+ $ manifest
24
+ >> Manifest.txt
25
+ >> a.txt
26
+ >> Manifest saved successfully
27
+
28
+ Check manifest:
29
+
30
+ $ touch b.txt
31
+ $ git add .
32
+ $ manifest check
33
+ >> Difference:
34
+ >>
35
+ >> -b.txt
36
+ >>
37
+ >> Manifest is invalid
38
+
39
+ $ manifest save
40
+ >> Manifest.txt
41
+ >> a.txt
42
+ >> b.txt
43
+ >> Manifest saved successfully
44
+
45
+ $ manifest check
46
+ >> Manifest.txt
47
+ >> a.txt
48
+ >> b.txt
49
+ >> Manifest is valid
50
+
51
+ See
52
+
53
+ $ manifest --help
54
+
55
+ ## Example scripting
56
+
57
+ ### Run each test separately
58
+
59
+ $ for i in $(manifest tests); do ruby -Ilib -Itest $i ; done
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'lib'
6
+ t.libs << 'test'
7
+ t.pattern = 'test/**/*_test.rb'
8
+ t.verbose = false
9
+ end
10
+
11
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/manifest ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $0 == __FILE__
4
+ $:.unshift 'lib/'
5
+ end
6
+
7
+ require 'rubygems/manifest/cli'
8
+ Rubygems::Manifest::CLI.start
@@ -0,0 +1,90 @@
1
+ require 'rubygems/manifest'
2
+ require 'optparse'
3
+
4
+ module Rubygems
5
+ class Manifest
6
+ class CLI
7
+ def self.start
8
+ new.start
9
+ end
10
+
11
+ def start
12
+ opts = OptionParser.new
13
+ opts.banner = "Usage: manifest [commands] [options]\n"
14
+ opts.banner << "\n"
15
+ opts.banner << "Commands:\n"
16
+ opts.banner << (" save".ljust(37)) + "Save to Manifest.txt [default]\n"
17
+ opts.banner << (" check".ljust(37)) + "Check Manifest.txt\n"
18
+ opts.banner << (" files".ljust(37)) + "Print files\n"
19
+ opts.banner << (" executables".ljust(37)) + "Print executables\n"
20
+ opts.banner << (" test-files".ljust(37)) + "Print all test files\n"
21
+ opts.banner << (" tests".ljust(37)) + "Print tests\n"
22
+
23
+ opts.banner << "\n"
24
+ opts.banner << "Options:\n"
25
+
26
+ opts.on("-v", "--version", "Print version") do
27
+ puts Rubygems::Manifest::VERSION
28
+ exit(0)
29
+ end
30
+
31
+ opts.parse!
32
+
33
+ manifest = Rubygems::Manifest.new
34
+
35
+ case ARGV[0]
36
+ when nil, 'save'
37
+ manifest.save
38
+
39
+ if manifest.files.none?
40
+ puts yellow("Manifest is empty")
41
+ else
42
+ puts manifest.files
43
+ $stderr.puts green("Manifest is saved successfully")
44
+ end
45
+ when 'check'
46
+ begin
47
+ manifest.check
48
+
49
+ if manifest.files.none?
50
+ puts yellow("Manifest is empty")
51
+ else
52
+ puts manifest.files
53
+ $stderr.puts green("Manifest is valid")
54
+ end
55
+ rescue => e
56
+ puts e.message
57
+ $stderr.puts red("Manifest is invalid")
58
+ exit 1
59
+ end
60
+ when 'files'
61
+ puts manifest.files
62
+ when 'executables'
63
+ puts manifest.executables
64
+ when 'test-files'
65
+ puts manifest.test_files
66
+ when 'tests'
67
+ puts manifest.tests
68
+ else
69
+ puts opts
70
+ end
71
+ end
72
+
73
+ def green(str)
74
+ color(str, 32)
75
+ end
76
+
77
+ def red(str)
78
+ color(str, 31)
79
+ end
80
+
81
+ def yellow(str)
82
+ color(str, 33)
83
+ end
84
+
85
+ def color(str, n)
86
+ "\e[#{n}m#{str}\e[0m"
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,5 @@
1
+ module Rubygems
2
+ class Manifest
3
+ VERSION = File.read(File.expand_path('../../../../VERSION', __FILE__)).strip
4
+ end
5
+ end
@@ -0,0 +1,54 @@
1
+ require "rubygems/manifest/version"
2
+
3
+ module Rubygems
4
+ class Manifest
5
+ def initialize(filename = ENV['MANIFEST'] || 'Manifest.txt')
6
+ @filename = filename
7
+ end
8
+
9
+ def files
10
+ @files ||= `git ls-files`.split($/)
11
+ end
12
+
13
+ def executables
14
+ files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ end
16
+
17
+ def test_files
18
+ files.grep(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ def tests
22
+ files.grep(%r{^(test|spec|features)(.*)(_test.rb|_spec.rb|\.feature)$})
23
+ end
24
+
25
+ def read
26
+ File.read(@filename).split("\n")
27
+ end
28
+
29
+ def save
30
+ File.open(@filename, 'w') { |f| f.puts(files) }
31
+ end
32
+
33
+ def check
34
+ str = diff_str
35
+
36
+ unless str == ''
37
+ fail "Difference:\n\n#{str}\n"
38
+ end
39
+ end
40
+
41
+ def diff
42
+ [read - files, files - read]
43
+ end
44
+
45
+ def diff_str
46
+ additions, deletions = diff
47
+
48
+ str = ''
49
+ deletions.each { |file| str << "-#{file}\n" }
50
+ additions.each { |file| str << "+#{file}\n" }
51
+ str
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubygems/manifest'
5
+
6
+ Gem::Specification.new do |spec|
7
+ manifest = Rubygems::Manifest.new
8
+ manifest.check
9
+
10
+ spec.name = "rubygems-manifest"
11
+ spec.version = Rubygems::Manifest::VERSION
12
+ spec.authors = ["Wojciech Mach"]
13
+ spec.email = ["wojtek@wojtekmach.pl"]
14
+ spec.description = "Create Manifest.txt"
15
+ spec.summary = "Create Manifest.txt"
16
+ spec.homepage = "https://github.com/wojtekmach/rubygems-manifest"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = manifest.files
20
+ spec.executables = manifest.executables
21
+ spec.test_files = manifest.test_files
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,124 @@
1
+ require 'minitest/autorun'
2
+ require 'rubygems/manifest'
3
+ require 'tmpdir'
4
+
5
+ describe "bin/manifest" do
6
+ describe "--version" do
7
+ it "prints current version" do
8
+ command("--version").strip.must_equal Rubygems::Manifest::VERSION
9
+ end
10
+ end
11
+
12
+ describe "--help" do
13
+ it "prints usage instructions" do
14
+ command("--help").must_include "Usage: manifest [commands] [options]"
15
+ end
16
+ end
17
+
18
+ def self.it(*args, &block)
19
+ super(*args, &proc { in_tmp_dir(&block) })
20
+ end
21
+
22
+ describe "check" do
23
+ it "prints warning when manifest is empty" do
24
+ `touch a.txt`
25
+ command('save')
26
+
27
+ command('check').must_include "Manifest is empty"
28
+ $?.success?.must_equal true
29
+ end
30
+
31
+ it "prints manifest when it's successful" do
32
+ `touch a.txt`
33
+ `git add .`
34
+ command('save')
35
+
36
+ command('check').must_equal "Manifest.txt\na.txt\n"
37
+ $?.success?.must_equal true
38
+ end
39
+
40
+ it "prints difference when it failed" do
41
+ `touch a.txt`
42
+ `git add .`
43
+ command('save')
44
+
45
+ `touch b.txt`
46
+ `git add .`
47
+ command('check').must_equal "Difference:\n\n-b.txt\n\n"
48
+ $?.success?.must_equal false
49
+ end
50
+ end
51
+
52
+ describe "save" do
53
+ def save
54
+ `touch a.txt`
55
+ `git add .`
56
+ command('save')
57
+ end
58
+
59
+ it "saves Manifest.txt" do
60
+ save
61
+ File.read('Manifest.txt').must_equal "Manifest.txt\na.txt\n"
62
+ end
63
+
64
+ it "prints the manifest" do
65
+ save.must_equal "Manifest.txt\na.txt\n"
66
+ end
67
+ end
68
+
69
+ def setup_fixtures
70
+ `mkdir bin lib test`
71
+ `touch bin/foo lib/foo.rb test/foo_test.rb test/test_helper.rb`
72
+ `git add .`
73
+ end
74
+
75
+ describe "files" do
76
+ it "prints files" do
77
+ setup_fixtures
78
+ command("files").must_equal "Manifest.txt\n" \
79
+ "bin/foo\n" \
80
+ "lib/foo.rb\n" \
81
+ "test/foo_test.rb\n" \
82
+ "test/test_helper.rb\n"
83
+ end
84
+ end
85
+
86
+ describe "executables" do
87
+ it "prints executable files" do
88
+ setup_fixtures
89
+ command("executables").must_equal "foo\n"
90
+ end
91
+ end
92
+
93
+ describe "test-files" do
94
+ it "prints test files" do
95
+ setup_fixtures
96
+ command("test-files").must_equal "test/foo_test.rb\n" \
97
+ "test/test_helper.rb\n"
98
+ end
99
+ end
100
+
101
+ describe "tests" do
102
+ it "prints tests" do
103
+ setup_fixtures
104
+ command("tests").must_equal "test/foo_test.rb\n"
105
+ end
106
+ end
107
+
108
+ private
109
+
110
+ BIN = File.expand_path('../../../bin/manifest', __FILE__)
111
+
112
+ def in_tmp_dir(&block)
113
+ Dir.mktmpdir('rubygems-manifest') do |dir|
114
+ Dir.chdir(dir)
115
+ `git init`
116
+ `touch Manifest.txt`
117
+ instance_eval(&block)
118
+ end
119
+ end
120
+
121
+ def command(*args)
122
+ `#{BIN} #{args.join(' ')} 2> /dev/null`
123
+ end
124
+ end
@@ -0,0 +1,28 @@
1
+ require 'minitest/autorun'
2
+ require 'rubygems/manifest'
3
+
4
+ describe Rubygems::Manifest do
5
+ let(:manifest) { Rubygems::Manifest.new }
6
+
7
+ it "returns files" do
8
+ manifest.files.must_include 'lib/rubygems/manifest.rb'
9
+ end
10
+
11
+ it "does not return files that are ignored" do
12
+ manifest.files.wont_include 'tmp/test.txt'
13
+ end
14
+
15
+ it "returns executables" do
16
+ manifest.executables.must_equal ['manifest']
17
+ end
18
+
19
+ it "returns all test files" do
20
+ manifest.test_files.must_include 'test/test_helper.rb'
21
+ manifest.test_files.must_include 'test/rubygems/manifest_test.rb'
22
+ end
23
+
24
+ it "returns tests" do
25
+ manifest.tests.wont_include 'test/test_helper.rb'
26
+ manifest.tests.must_include 'test/rubygems/manifest_test.rb'
27
+ end
28
+ end
File without changes
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubygems-manifest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wojciech Mach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Create Manifest.txt
42
+ email:
43
+ - wojtek@wojtekmach.pl
44
+ executables:
45
+ - manifest
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - .travis.yml
51
+ - Gemfile
52
+ - HISTORY.md
53
+ - LICENSE.txt
54
+ - Manifest.txt
55
+ - README.md
56
+ - Rakefile
57
+ - VERSION
58
+ - bin/manifest
59
+ - lib/rubygems/manifest.rb
60
+ - lib/rubygems/manifest/cli.rb
61
+ - lib/rubygems/manifest/version.rb
62
+ - rubygems-manifest.gemspec
63
+ - test/bin/manifest_test.rb
64
+ - test/rubygems/manifest_test.rb
65
+ - test/test_helper.rb
66
+ homepage: https://github.com/wojtekmach/rubygems-manifest
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.0.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Create Manifest.txt
90
+ test_files:
91
+ - test/bin/manifest_test.rb
92
+ - test/rubygems/manifest_test.rb
93
+ - test/test_helper.rb