distribute 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore
6
+
7
+ # Ignore all of the generated gem stuff
8
+ /pkg
9
+ /*.gem
10
+
11
+ # Ignore bundler config
12
+ /.bundle
13
+ /Gemfile.lock
14
+
15
+ # Ignore all bundler caching
16
+ /vendor/cache
17
+ /vendor/ruby
18
+
19
+ # Ignore all tempfiles
20
+ /tmp
21
+
22
+ # Ignores that should be in the global gitignore
23
+ # /*.rbc
24
+ # /.config
25
+ # /.yardoc
26
+ # /InstalledFiles
27
+ # /_yardoc
28
+ # /coverage/
29
+ # /doc/
30
+ # /lib/bundler/man/
31
+ # /rdoc/
32
+ # /spec/reports/
33
+ # /test/tmp/
34
+ # /test/version_tmp/
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p362@distribute"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.8 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ - 1.9.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ 1.0.0 / 2012-MM-DD
2
+ ==================
3
+
4
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in distribute.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kurtis Rainbolt-Greene
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/README.md ADDED
@@ -0,0 +1,98 @@
1
+ Distribute
2
+ ----------
3
+
4
+ distribute is a gem for creating distributions of your code.
5
+ If you have any statically released binaries or files then this will help you.
6
+ Lots of people used Github Downloads before, but now can't.
7
+ With distribute this is made much easier.
8
+
9
+ Requires git, at the moment.
10
+
11
+
12
+ Using Distribute
13
+ ================
14
+
15
+ Either use in a rake task:
16
+
17
+ ``` ruby
18
+ files = [
19
+ 'bin/whatever',
20
+ 'dist/thing.js',
21
+ 'dist/thing.min.js'
22
+ ]
23
+
24
+ version = File.read("VERSION")
25
+
26
+ desc "Releasing the new binary"
27
+ task :release do
28
+ Release.new(files, version).distribute!
29
+ end
30
+
31
+ desc "Releasing the latest binary"
32
+ task :latest do
33
+ Latest.new(files).distribute!
34
+ end
35
+ ```
36
+
37
+ Or the binary provided by us:
38
+
39
+ ``` ruby
40
+ distribute --version=1.0.0 ember.js ember.min.js [filename...]
41
+ ```
42
+
43
+ For more information, check the [wiki](/wiki)
44
+
45
+
46
+ Installing Distribute
47
+ =====================
48
+
49
+ Add this line to your application's Gemfile:
50
+
51
+ gem 'distribute'
52
+
53
+ And then execute:
54
+
55
+ $ bundle
56
+
57
+ Or install it yourself as:
58
+
59
+ $ gem install distribute
60
+
61
+
62
+ Contributing
63
+ ============
64
+
65
+ 1. Fork it
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create new Pull Request
70
+
71
+ A list of past contributors:
72
+
73
+
74
+ License
75
+ =======
76
+
77
+ Copyright (c) 2013 Kurtis Rainbolt-Greene
78
+
79
+ MIT License
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining
82
+ a copy of this software and associated documentation files (the
83
+ "Software"), to deal in the Software without restriction, including
84
+ without limitation the rights to use, copy, modify, merge, publish,
85
+ distribute, sublicense, and/or sell copies of the Software, and to
86
+ permit persons to whom the Software is furnished to do so, subject to
87
+ the following conditions:
88
+
89
+ The above copyright notice and this permission notice shall be
90
+ included in all copies or substantial portions of the Software.
91
+
92
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
93
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
95
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
96
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
97
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
98
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'yard'
6
+
7
+ begin
8
+ Bundler.setup :default, :development
9
+ rescue Bundler::BundlerError => error
10
+ $stderr.puts error.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit error.status_code
13
+ end
14
+
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ desc "Run all of the tests"
18
+ Rake::TestTask.new do |config|
19
+ config.libs << 'test'
20
+ config.pattern = 'test/**/*_test*'
21
+ # config.verbose = true
22
+ # config.warning = true
23
+ end
24
+
25
+ desc "Generate all of the docs"
26
+ YARD::Rake::YardocTask.new do |config|
27
+ config.files = Dir['lib/**/*.rb']
28
+ end
29
+
30
+ desc 'Default: run tests, and generate docs'
31
+ task :default => [ :test, :yard ]
data/bin/distribute ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'distribute'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: distribute [--version|=1.0.0] file [file file...]"
10
+
11
+ opts.on("--version=", "Specifies a version") do |version|
12
+ options[:version] = version
13
+ end
14
+ end.parse!
15
+
16
+ case
17
+ when options[:version]
18
+ Release.new(ARGV, options[:version]).distribute!
19
+ when ARGV.any?
20
+ Latest.new(ARGV).distribute!
21
+ else
22
+ "You didn't use this binary right."
23
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'distribute/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "distribute"
8
+ gem.version = Distribute::VERSION
9
+ gem.authors = ["Kurtis Rainbolt-Greene"]
10
+ gem.email = ["me@kurtisrainboltgreene.name"]
11
+ gem.summary = %q{A small distribution method for binaries or libraries.}
12
+ gem.description = gem.summary
13
+ gem.homepage = "http://krainboltgreene.github.com/distribute"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'yard'
21
+ gem.add_development_dependency 'kramdown'
22
+ # gem.add_runtime_dependency 'gemname', '~> 1.0'
23
+ # gem.add_development_dependency 'gemname', '~> 1.0'
24
+ end
data/lib/distribute.rb ADDED
@@ -0,0 +1,113 @@
1
+ require_relative "distribute/command"
2
+ require_relative "distribute/latest"
3
+ require_relative "distribute/release"
4
+ require_relative "distribute/version"
5
+
6
+ class Distribute
7
+ attr_accessor :files, :version
8
+
9
+ def initialize(files, version = nil)
10
+ @files = files
11
+ @version = version
12
+ end
13
+
14
+ def distribute!
15
+ (version ? build_release : build_latest).distribute!
16
+ end
17
+
18
+ private
19
+
20
+ def build_latest
21
+ Latest.new files, version
22
+ end
23
+
24
+ def build_release
25
+ Release.new files, version
26
+ end
27
+
28
+ def checkout_branch(name, orphan = false)
29
+ Command.new("git checkout #{"--orphan" if orphan} #{name}").send!
30
+ end
31
+
32
+ def has_unsaved_changes?
33
+ !Command.new("git status --porcelain").send!.empty?
34
+ end
35
+
36
+ def branch_exists?
37
+ Command.new("git branch").send!.include? type
38
+ end
39
+
40
+ def check_for_unsaved_changes
41
+ raise "You have unsaved changes!" if has_unsaved_changes?
42
+ end
43
+
44
+ def change_branches
45
+ branch_exists? ? checkout_branch(type) : checkout_branch(type, true)
46
+ end
47
+
48
+ def clear_working_index
49
+ Command.new("git rm -rf .").send!
50
+ end
51
+
52
+ def add_files_to_index
53
+ files.each &method(:add_file_to_index)
54
+ end
55
+
56
+ def add_file_to_index(file)
57
+ Command.new("git add #{file}").send!
58
+ end
59
+
60
+ def move_files
61
+ files.each &method(:move_file) if files_exist?
62
+ end
63
+
64
+ def files_exist?
65
+ files.all? { |file| File.exists? file }
66
+ end
67
+
68
+ def move_file(file)
69
+ Command.new("mv #{file} #{new_file file}").send!
70
+ end
71
+
72
+ def get_new_files
73
+ files.map! &method(:new_file)
74
+ end
75
+
76
+ def new_file(file)
77
+ "#{file_name file}.#{file_extention file}"
78
+ end
79
+
80
+ def file_name(file)
81
+ split_file_name(file).shift
82
+ end
83
+
84
+ def file_extention(file)
85
+ split_file_name(file).tap(&:shift).join "."
86
+ end
87
+
88
+ def file_from_path(file)
89
+ file.split(File::SEPARATOR).last
90
+ end
91
+
92
+ def split_file_name(file)
93
+ file_from_path(file).split "."
94
+ end
95
+
96
+ def commit_index
97
+ Command.new("git commit -m 'Adding the #{type} distribution'").send!
98
+ end
99
+
100
+ def push
101
+ Command.new("git push origin #{type}").send!
102
+ end
103
+
104
+ def setup_branch
105
+ check_for_unsaved_changes
106
+ change_branches
107
+ clear_working_index
108
+ move_files
109
+ get_new_files
110
+ add_files_to_index
111
+ commit_index
112
+ end
113
+ end
@@ -0,0 +1,7 @@
1
+ class Distribute
2
+ class Command < Struct.new(:command)
3
+ def send!
4
+ `#{command}`
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class Latest < Distribute
2
+ def distribute!
3
+ setup_branch
4
+ push
5
+ end
6
+
7
+ def type
8
+ "latest"
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class Release < Distribute
2
+ def distribute!
3
+ setup_branch
4
+ tag_branch
5
+ push
6
+ end
7
+
8
+ def type
9
+ "release"
10
+ end
11
+
12
+ private
13
+
14
+ def tag_branch
15
+ Command.new("git tag release-v#{version}").send!
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ class Distribute
2
+ VERSION = "1.0.0"
3
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'distribute'
2
+
3
+ class Distribute
4
+ class Command
5
+ def send!
6
+ command
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,46 @@
1
+ require 'minitest/autorun'
2
+ require 'helper'
3
+
4
+ class TestDistribute < MiniTest::Unit::TestCase
5
+ def setup
6
+ system "mkdir tmp/" unless File.exists? "tmp"
7
+ @files = ['tmp/example1.file', 'tmp/example2.file', 'tmp/example3.file']
8
+ system "touch #{@files.join(" ")}"
9
+ @latest = Latest.new @files
10
+ end
11
+
12
+ def test_get_new_files
13
+ expected = ['example1.file', 'example2.file', 'example3.file']
14
+ @latest.send :get_new_files
15
+ actual = @latest.files
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ def test_file_from_path
20
+ expected = 'example1.file'
21
+ actual = @latest.send :file_from_path, 'tmp/example1.file'
22
+ assert_equal expected, actual
23
+ end
24
+
25
+ def test_file_extention
26
+ expected = 'file'
27
+ actual = @latest.send :file_extention, 'example1.file'
28
+ assert_equal expected, actual
29
+ end
30
+
31
+ def test_files_exist?
32
+ expected = true
33
+ actual = @latest.send :files_exist?
34
+ assert_equal expected, actual
35
+
36
+ @latest.files = ["foo", "far", "fong"]
37
+ expected = false
38
+ actual = @latest.send :files_exist?
39
+ assert_equal expected, actual
40
+
41
+ @latest.files = @files << "fong"
42
+ expected = false
43
+ actual = @latest.send :files_exist?
44
+ assert_equal expected, actual
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: distribute
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kurtis Rainbolt-Greene
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: kramdown
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A small distribution method for binaries or libraries.
47
+ email:
48
+ - me@kurtisrainboltgreene.name
49
+ executables:
50
+ - distribute
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rvmrc
56
+ - .travis.yml
57
+ - CHANGELOG.md
58
+ - Gemfile
59
+ - LICENSE.txt
60
+ - README.md
61
+ - Rakefile
62
+ - bin/distribute
63
+ - distribute.gemspec
64
+ - lib/distribute.rb
65
+ - lib/distribute/command.rb
66
+ - lib/distribute/latest.rb
67
+ - lib/distribute/release.rb
68
+ - lib/distribute/version.rb
69
+ - test/helper.rb
70
+ - test/lib/distribute_test.rb
71
+ homepage: http://krainboltgreene.github.com/distribute
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
84
+ - 0
85
+ hash: -546729852826778510
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
93
+ - 0
94
+ hash: -546729852826778510
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.24
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: A small distribution method for binaries or libraries.
101
+ test_files:
102
+ - test/helper.rb
103
+ - test/lib/distribute_test.rb
104
+ has_rdoc: