berry 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Bryan Goines
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File without changes
@@ -0,0 +1,81 @@
1
+ require 'small/string'
2
+ require 'path2'
3
+ require 'yaml'
4
+
5
+ class Berry
6
+
7
+ DEFAULT_FILES = /(README|LICENSE|bin\/|lib\/)/
8
+
9
+ def initialize(name, &block)
10
+ @name = name.to_s.downcase
11
+ @namespace = @name.capitalize.constantize rescue nil
12
+ @path = Path(".", :recursive => true, :short => true)
13
+ auto_require_version!
14
+ specification(&block) if block_given?
15
+ end
16
+
17
+ def specification(&block)
18
+ @gemspec = Gem::Specification.new(&block)
19
+ end
20
+
21
+ def to_spec
22
+ @gemspec.name ||= @name
23
+ @gemspec.version ||= default_version
24
+ @gemspec.summary ||= "WIP"
25
+ @gemspec.author ||= default_author
26
+ @gemspec.email ||= default_email
27
+ @gemspec.description ||= @gemspec.summary
28
+ @gemspec.homepage ||= default_homepage
29
+ @gemspec.executables = (@gemspec.executables + default_executables).uniq
30
+ @gemspec.files = (@gemspec.files + default_files).uniq
31
+ @gemspec.rubyforge_project = "nowarning"
32
+ @gemspec
33
+ end
34
+
35
+ private
36
+
37
+ def config
38
+ berryrc = Path("~/").join(".berryrc")
39
+ @config ||= berryrc.exists? ? YAML.load_file(berryrc.current) : {}
40
+ end
41
+
42
+ def auto_require_version!
43
+ libpath = @path.join("lib/#{@name}").find("version.rb")
44
+ return unless libpath
45
+ begin
46
+ require libpath
47
+ rescue LoadError => e
48
+ puts "Unable to require #{@name}/version.rb.. skipping"
49
+ end
50
+ end
51
+
52
+ def default_version
53
+ @namespace ? @namespace.const_get("VERSION") : "0.0.0"
54
+ end
55
+
56
+ def default_author
57
+ config['author'] || %x{ git config user.name }.chomp
58
+ end
59
+
60
+ def default_email
61
+ config['email'] || %x{ git config user.email }.chomp
62
+ end
63
+
64
+ def default_files
65
+ @path.grep(DEFAULT_FILES)
66
+ end
67
+
68
+ def default_executables
69
+ @path.grep(/\/bin/).reject {|f| f.match(/bin$/) }.map &File.method(:basename)
70
+ end
71
+
72
+ def default_homepage
73
+ config['github'] ? "#{config['github']}/#{@name}" : "https://rubygems.org/gems/#{@name}"
74
+ end
75
+
76
+ end
77
+
78
+ def Berry(name, &block)
79
+ Berry.new(name, &block).to_spec
80
+ end
81
+
@@ -0,0 +1,112 @@
1
+ begin
2
+ require 'path2'
3
+ rescue LoadError => e
4
+ require 'rubygems'
5
+ require 'path2'
6
+ end
7
+
8
+ class Berry
9
+ class GemTasks
10
+ include Rake::DSL if defined?(Rake::DSL)
11
+
12
+ def self.install_tasks!
13
+ new.install
14
+ end
15
+
16
+ def initialize
17
+ @path = Path(Dir.pwd, :recursive => true, :short => false)
18
+ @gemspec = @path.find(".gemspec")
19
+ raise "Unable to locate .gemspec file" unless @gemspec
20
+ end
21
+
22
+ def install
23
+ desc "Build #{pkg_file} into the pkg/ directory"
24
+ task 'build' do
25
+ build_gem
26
+ end
27
+
28
+ desc "Install #{pkg_file} into your system"
29
+ task 'install' do
30
+ install_gem
31
+ end
32
+
33
+ desc "Push your #{pkg_file} to RubyGems.org"
34
+ task 'push' do
35
+ push_gem
36
+ end
37
+
38
+ desc "Yank #{pkg_file} from RubyGems"
39
+ task 'yank' do
40
+ yank_gem
41
+ end
42
+
43
+ desc "Uninstall #{pkg_file}"
44
+ task 'uninstall' do
45
+ uninstall_gem
46
+ end
47
+
48
+ desc "Clean up pkg files"
49
+ task 'clean' do
50
+ cleanup
51
+ end
52
+ end
53
+
54
+ def build_gem
55
+ sh "gem build #{@gemspec}"
56
+ FileUtils.mkdir_p @path.join("pkg").current
57
+ FileUtils.mv(built_gem_path, [@path.join("pkg").current, pkg_file].join("/"))
58
+ puts "#{pkg.name} (#{pkg.version}) built to pkg/#{pkg_file}"
59
+ built_gem_path("pkg")
60
+ end
61
+
62
+ def install_gem
63
+ gem_file = build_gem
64
+ out, _ = sh "gem install #{gem_file}"
65
+ raise "Unable to install #{pkg_file}, run `gem install #{pkg_file}` for more details" unless out[/Successfully installed/]
66
+ puts "#{pkg.name} (#{pkg.version}) installed"
67
+ end
68
+
69
+ def yank_gem
70
+ sh "gem yank #{pkg.name} -v #{pkg.version}"
71
+ puts "#{pkg.name} (#{pkg.version}) yanked from RubyGems"
72
+ end
73
+
74
+ def uninstall_gem
75
+ sh "gem unstall #{pkg.name} -v #{pkg.version}"
76
+ puts "#{pkg.name} (#{pkg.version}) uninstalled"
77
+ end
78
+
79
+ def push_gem
80
+ sh "gem push #{built_gem_path("pkg")}"
81
+ puts "#{pkg.name} (#{pkg.version}) pushed to RubyGems"
82
+ end
83
+
84
+ def cleanup
85
+ sh "rm -rf pkg/"
86
+ puts "pkg/ removed"
87
+ end
88
+
89
+ def pkg
90
+ @package ||= Gem::Specification.load(@gemspec)
91
+ end
92
+
93
+ def pkg_file
94
+ "#{pkg.name}-#{pkg.version}.gem"
95
+ end
96
+
97
+ def built_gem_path(dir = nil)
98
+ dir ? @path.reload.join(dir).find(pkg_file) : @path.reload.find(pkg_file)
99
+ end
100
+
101
+ def sh(cmd)
102
+ cmd << " 2>&1"
103
+ out = ''
104
+ Dir.chdir(@path.current) do
105
+ out = `#{cmd}`
106
+ end
107
+ [out, $?]
108
+ end
109
+ end
110
+ end
111
+
112
+ Berry::GemTasks.install_tasks!
@@ -0,0 +1,3 @@
1
+ class Berry
2
+ VERSION = "0.1.1"
3
+ end
metadata CHANGED
@@ -1,94 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: berry
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 0
10
- version: 0.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bryan Goines
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-11-16 00:00:00 -06:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: parka
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: small
16
+ requirement: &70298644780000 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
32
- requirement: *id001
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
33
23
  prerelease: false
34
- type: :development
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70298644780000
25
+ - !ruby/object:Gem::Dependency
26
+ name: path2
27
+ requirement: &70298644798840 !ruby/object:Gem::Requirement
38
28
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- requirement: *id002
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
47
34
  prerelease: false
35
+ version_requirements: *70298644798840
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70298644797680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
48
44
  type: :development
45
+ prerelease: false
46
+ version_requirements: *70298644797680
49
47
  description: WIP
50
48
  email: bryann83@gmail.com
51
49
  executables: []
52
-
53
50
  extensions: []
54
-
55
51
  extra_rdoc_files: []
56
-
57
- files: []
58
-
59
- has_rdoc: true
60
- homepage: http://rubygems.org/gems/berry
52
+ files:
53
+ - ./LICENSE
54
+ - ./README.md
55
+ - ./lib/berry/gem_tasks.rb
56
+ - ./lib/berry/version.rb
57
+ - ./lib/berry.rb
58
+ homepage: https://github.com/bry4n/berry
61
59
  licenses: []
62
-
63
60
  post_install_message:
64
61
  rdoc_options: []
65
-
66
- require_paths:
62
+ require_paths:
67
63
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
64
+ required_ruby_version: !ruby/object:Gem::Requirement
69
65
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
75
71
  - 0
76
- version: "0"
77
- required_rubygems_version: !ruby/object:Gem::Requirement
72
+ hash: -1887652882941291305
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
74
  none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ segments:
84
80
  - 0
85
- version: "0"
81
+ hash: -1887652882941291305
86
82
  requirements: []
87
-
88
83
  rubyforge_project: nowarning
89
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.8.11
90
85
  signing_key:
91
86
  specification_version: 3
92
87
  summary: WIP
93
88
  test_files: []
94
-