round_cloud 0.1.1

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: acacb43d33aad4f77dab3d3bdce2d4d9181a61c2
4
+ data.tar.gz: 00663de84a0c0da4e55a02e36415242b795dc3b2
5
+ SHA512:
6
+ metadata.gz: 7ee2d6926409b1aaf40b3735d7bb1645aa2b47169a4870ec9b96de1da8273db17016821903fe5c67117b9f10444fa3bd9ec0aecad35fa7275c48934a20e79956
7
+ data.tar.gz: 74cfe98ecb93ace5df855b381f0de882a2707ec61b169cf022e9c4d4ea45eb750349e0348bd3cdc3087e6f6a94ffac5b79692486c78acf35a34ff6b2f2e9809f
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format progress
3
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in round_cloud.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # RoundCloud
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/round_cloud`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'round_cloud'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install round_cloud
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec round_cloud` to use the gem in this directory, ignoring other installed copies of this gem.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/round_cloud.
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "round_cloud"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/round_cloud ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'round_cloud'
4
+
5
+ RoundCloud::CLI.start(ARGV)
@@ -0,0 +1,5 @@
1
+ module RoundCloud
2
+ autoload :PackageCloud, 'round_cloud/package_cloud'
3
+ autoload :CLI, 'round_cloud/cli'
4
+ autoload :VERSION, 'round_cloud/version'
5
+ end
@@ -0,0 +1,97 @@
1
+ require 'bundler/gem_helper'
2
+ require 'thor'
3
+
4
+ module RoundCloud
5
+ class RoundCloud::CLI < Thor
6
+ GEM_VERSION_PLACEHOLDER = '\b\S\+::VERSION'
7
+
8
+ attr_reader :package_cloud
9
+
10
+ desc 'release', 'release new version of a package and push to packagecloud.io'
11
+ option :pre, type: :boolean, default: false
12
+ def release
13
+ if options[:pre]
14
+ setup_prerelease_env!
15
+ else
16
+ if gemspec_version.prerelease?
17
+ ui.error "Cannot release version #{gemspec_version} as stable!"
18
+ exit 1
19
+ end
20
+ end
21
+ do_release
22
+ end
23
+
24
+ private
25
+
26
+ def setup_prerelease_env!
27
+ @prerelease = true
28
+
29
+ if gemspec_version.prerelease?
30
+ add_build_number_to_gemspec_version
31
+ else
32
+ ui.error "Cannot release version `#{gemspec_version}' as prerelease!"
33
+ exit 1
34
+ end
35
+ end
36
+
37
+ def do_release
38
+ with_uniq_gemspec_version { package_cloud.publish gem_helper.build_gem }
39
+ end
40
+
41
+ def prerelease?
42
+ !!@prerelease
43
+ end
44
+
45
+ def with_uniq_gemspec_version
46
+ if prerelease?
47
+ change_version_in_gemspec
48
+ yield
49
+ revert_version_in_gemspec
50
+ else
51
+ yield
52
+ end
53
+ rescue PackageCloud::MissingConfigError => e
54
+ ui.error 'Cannot proceed. Exiting.'
55
+ exit 1
56
+ end
57
+
58
+ def change_version_in_gemspec
59
+ `sed -i -e 's/#{GEM_VERSION_PLACEHOLDER}/"#{gemspec_version}"/' #{gem_helper.spec_path}`
60
+ end
61
+
62
+ def revert_version_in_gemspec
63
+ `sed -i -e 's/"#{gemspec_version}"/#{GEM_VERSION_PLACEHOLDER}/' #{gem_helper.spec_path}`
64
+ end
65
+
66
+ # If there is no build number in gemspec version, add it.
67
+ # Fail if there is no build number defined. We cannot push uniq build without build number.
68
+ def add_build_number_to_gemspec_version
69
+ build_number = ENV.fetch('CIRCLE_BUILD_NUM') do
70
+ ui.error 'Cannot find build number!'
71
+ exit 1
72
+ end
73
+
74
+ return if gemspec_version.version.end_with? ".#{build_number}"
75
+
76
+ gem_helper.gemspec.version = Gem::Version.new "#{gemspec_version}.#{build_number}"
77
+ end
78
+
79
+ def ui
80
+ @ui ||= Bundler::UI::Shell.new
81
+ end
82
+
83
+ def gem_helper
84
+ @gem_helper ||= Bundler::GemHelper.new
85
+ Bundler.ui = Bundler::UI::Silent.new
86
+ @gem_helper
87
+ end
88
+
89
+ def gemspec_version
90
+ gem_helper.gemspec.version
91
+ end
92
+
93
+ def package_cloud
94
+ @package_cloud ||= PackageCloud.new ui, gem_helper
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,66 @@
1
+ module RoundCloud
2
+ class PackageCloud
3
+ TOKEN = 'PACKAGECLOUD_TOKEN'
4
+ USER = 'PACKAGECLOUD_REPO_USER'
5
+ REPO = 'PACKAGECLOUD_REPO_NAME'
6
+
7
+ MissingConfigError = Class.new StandardError
8
+
9
+ attr_reader :ui, :gem_helper
10
+
11
+ def initialize(ui, gem_helper)
12
+ @ui = ui
13
+ @gem_helper = gem_helper
14
+ end
15
+
16
+ def publish(package_path)
17
+ ui.info "pushing #{package_path} package..."
18
+
19
+ cmd = release_cmd package_path
20
+ out = run_command cmd
21
+ version = gem_helper.gemspec.version
22
+
23
+ if '{}' == out
24
+ ui.confirm "Successfully pushed new package version `#{version}'"
25
+ ui.confirm "Add to Gemfile: \"gem '#{gem_helper.gemspec.name}', '#{version}'\""
26
+ else
27
+ ui.error "Failed to push version `#{version}', error: `#{out}'"
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def run_command(cmd)
34
+ `#{cmd}`
35
+ end
36
+
37
+ def token
38
+ ENV.fetch(TOKEN) do
39
+ ui.error "Failed to find env var with packagecloud token. Create env var `#{TOKEN}'"
40
+ fail MissingConfigError
41
+ end
42
+ end
43
+
44
+ def repo_name
45
+ ENV.fetch(REPO) do
46
+ ui.error "Failed to find env var with packagecloud repo name. Create env var `#{REPO}'"
47
+ fail MissingConfigError
48
+ end
49
+ end
50
+
51
+ def repo_user
52
+ ENV.fetch(USER) do
53
+ ui.error "Failed to find env var with packagecloud repo user. Create env var `#{USER}'"
54
+ fail MissingConfigError
55
+ end
56
+ end
57
+
58
+ def api_uri
59
+ "https://#{token}:@packagecloud.io/api/v1/repos/#{repo_user}/#{repo_name}/packages.json"
60
+ end
61
+
62
+ def release_cmd(package_path)
63
+ %Q(curl -X POST #{api_uri} -F 'package[package_file]=@#{package_path}' 2>/dev/null)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module RoundCloud
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'round_cloud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'round_cloud'
8
+ spec.version = RoundCloud::VERSION
9
+ spec.authors = ['Aliaksandr Rahalevich']
10
+ spec.email = ['saksmlz@gmail.com']
11
+
12
+ spec.summary = %q{Provides executable for building and packaging gem}
13
+ spec.description = %q{Allows to build gem on circle ci and publish to packagecloud.io}
14
+ spec.homepage = 'http://github.com'
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+ else
21
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'thor'
30
+
31
+ spec.add_development_dependency 'bundler', '~> 1.10'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec'
34
+ spec.add_development_dependency 'pry-doc'
35
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: round_cloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Aliaksandr Rahalevich
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-doc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Allows to build gem on circle ci and publish to packagecloud.io
84
+ email:
85
+ - saksmlz@gmail.com
86
+ executables:
87
+ - round_cloud
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/round_cloud
100
+ - lib/round_cloud.rb
101
+ - lib/round_cloud/cli.rb
102
+ - lib/round_cloud/package_cloud.rb
103
+ - lib/round_cloud/version.rb
104
+ - round_cloud.gemspec
105
+ homepage: http://github.com
106
+ licenses: []
107
+ metadata:
108
+ allowed_push_host: https://rubygems.org
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.6
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Provides executable for building and packaging gem
129
+ test_files: []
130
+ has_rdoc: