auto_tag_version 0.0.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: 60225e47f0ff28d5b992e944694a69d88c34f2ef
4
+ data.tar.gz: b9230a1cb2dde00383b5fa65f117989ca0677b25
5
+ SHA512:
6
+ metadata.gz: 2e0bd632eaabb484ba050287bebdc7ba8d6e8862b21ab8260c9aac60cb009671940800be833f88e08f436c84b99bcd356e60dd87d3080660863dfd19d3aa0d4f
7
+ data.tar.gz: 911f6c0a0793c208e650222f07142cf3c43b52d0ea003e337c4df63ebf8864b744701fabbffa846b6634ef908ae3106f3ccb787f563044fa8ce2dc65b68b54d3
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ auto-tag-version
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p598
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ auto_tag_version (0.0.1)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (4.2.5)
11
+ actionview (= 4.2.5)
12
+ activesupport (= 4.2.5)
13
+ rack (~> 1.6)
14
+ rack-test (~> 0.6.2)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (4.2.5)
18
+ activesupport (= 4.2.5)
19
+ builder (~> 3.1)
20
+ erubis (~> 2.7.0)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ activesupport (4.2.5)
24
+ i18n (~> 0.7)
25
+ json (~> 1.7, >= 1.7.7)
26
+ minitest (~> 5.1)
27
+ thread_safe (~> 0.3, >= 0.3.4)
28
+ tzinfo (~> 1.1)
29
+ builder (3.2.2)
30
+ diff-lcs (1.2.5)
31
+ erubis (2.7.0)
32
+ i18n (0.7.0)
33
+ json (1.8.3)
34
+ loofah (2.0.3)
35
+ nokogiri (>= 1.5.9)
36
+ mini_portile2 (2.0.0)
37
+ minitest (5.8.3)
38
+ nokogiri (1.6.7)
39
+ mini_portile2 (~> 2.0.0.rc2)
40
+ rack (1.6.4)
41
+ rack-test (0.6.3)
42
+ rack (>= 1.0)
43
+ rails-deprecated_sanitizer (1.0.3)
44
+ activesupport (>= 4.2.0.alpha)
45
+ rails-dom-testing (1.0.7)
46
+ activesupport (>= 4.2.0.beta, < 5.0)
47
+ nokogiri (~> 1.6.0)
48
+ rails-deprecated_sanitizer (>= 1.0.1)
49
+ rails-html-sanitizer (1.0.2)
50
+ loofah (~> 2.0)
51
+ railties (4.2.5)
52
+ actionpack (= 4.2.5)
53
+ activesupport (= 4.2.5)
54
+ rake (>= 0.8.7)
55
+ thor (>= 0.18.1, < 2.0)
56
+ rake (10.4.2)
57
+ rspec (3.4.0)
58
+ rspec-core (~> 3.4.0)
59
+ rspec-expectations (~> 3.4.0)
60
+ rspec-mocks (~> 3.4.0)
61
+ rspec-core (3.4.1)
62
+ rspec-support (~> 3.4.0)
63
+ rspec-expectations (3.4.0)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.4.0)
66
+ rspec-mocks (3.4.0)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.4.0)
69
+ rspec-support (3.4.1)
70
+ thor (0.19.1)
71
+ thread_safe (0.3.5)
72
+ tzinfo (1.2.2)
73
+ thread_safe (~> 0.1)
74
+
75
+ PLATFORMS
76
+ ruby
77
+
78
+ DEPENDENCIES
79
+ auto_tag_version!
80
+ rake
81
+ rspec
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Auto Tag Version
2
+ Create/Update the application version file of your Rails app and automatically create the git tag.
3
+
4
+ ## Prerequisite
5
+
6
+ - For now, only Rails application (Tested Rails 3 and 4)
7
+ - *Gems support comming soon!*
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```
14
+ gem 'auto_tag_version'
15
+ ```
16
+
17
+ When you need to create a tag:
18
+
19
+ ```
20
+ $ rake autotag TAG=10.24.5
21
+ ```
22
+
23
+ ## How it works
24
+
25
+ Considering you application name is "TestAPP", this code above will create a file in "test_app/config/initializers/app_version.rb" with the content like:
26
+
27
+ ```
28
+ module TestAPP
29
+ VERSION = 10.24.5
30
+ end
31
+ ```
32
+ And them will commit this file and create a git tag. **(You need to push it manually!)**
33
+
34
+ You can get the version number in your application as **"TestAPP::VERSION"**
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('lib/tasks/*.rake').each { |r| import r }
@@ -0,0 +1,20 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'auto_tag_version/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "auto_tag_version"
7
+ s.version = AutoTagVersion::VERSION
8
+ s.summary = "Generate auto tag"
9
+ s.description = "Generate auto tag"
10
+ s.authors = ["Rafael Biriba"]
11
+ s.email = ["biribarj@gmail.com"]
12
+ s.files = `git ls-files -z`.split("\x0")
13
+ s.require_paths = ["lib"]
14
+ s.homepage = "https://github.com/rafaelbiriba/auto_tag_version"
15
+ s.license = "MIT"
16
+
17
+ s.add_dependency "railties"
18
+ s.add_development_dependency "rake"
19
+ s.add_development_dependency "rspec"
20
+ end
@@ -0,0 +1,12 @@
1
+ require 'auto_tag_version'
2
+ require 'rails'
3
+
4
+ module AutoTagVersion
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :autotag
7
+
8
+ rake_tasks do
9
+ load 'tasks/autotag.rake'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ module AutoTagVersion
2
+
3
+ def self.tag tag = nil
4
+ @tag = @tag || tag
5
+ end
6
+
7
+ def self.content
8
+ content = "module #{app}; VERSION = '#{tag}'; end\n"
9
+ content += "# This file is created automatically by auto_tag_version gem\n"
10
+ content += "# Documentation at https://github.com/rafaelbiriba/auto_tag_version"
11
+ end
12
+
13
+ def self.app
14
+ Rails.application.class.parent_name
15
+ end
16
+
17
+ def self.version_file
18
+ File.join("config", "initializers", "app_version.rb")
19
+ end
20
+
21
+ def self.create_version_file
22
+ File.open(version_file, "w") { |f| f.write(content) }
23
+ end
24
+
25
+ def self.commit_and_create_tag
26
+ `git add #{version_file} && git commit -m "Bumping version #{tag}" && git tag #{tag}`
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module AutoTagVersion
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ module AutoTagVersion
2
+ require 'auto_tag_version/railtie' if defined?(Rails)
3
+ end
4
+
5
+ require 'auto_tag_version/utils'
@@ -0,0 +1,12 @@
1
+ desc "Create/Update the APP VERSION and create the git tag. USAGE: rake autotag TAG=0.0.0"
2
+ task :autotag do
3
+ if !defined?(Rails)
4
+ puts "Rails app not found!"
5
+ elsif ENV["TAG"].blank?
6
+ puts "TAG not found! USAGE: rake autotag TAG=0.0.0"
7
+ else
8
+ AutoTagVersion.tag ENV["TAG"]
9
+ AutoTagVersion.create_version_file
10
+ AutoTagVersion.commit_and_create_tag
11
+ end
12
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe AutoTagVersion do
4
+ subject do
5
+ AutoTagVersion
6
+ end
7
+
8
+ describe ".tag" do
9
+ it "should save and return the tag" do
10
+ subject.tag 123
11
+ expect(subject.tag).to be 123
12
+ end
13
+ end
14
+
15
+
16
+ describe ".content" do
17
+ before do
18
+ allow(subject).to receive(:app).and_return("App")
19
+ allow(subject).to receive(:tag).and_return("1.1.1")
20
+ end
21
+
22
+ it "should create the content for version file" do
23
+ expect(subject.content).to eql "module App; VERSION = '1.1.1'; end\n# This file is created automatically by auto_tag_version gem\n# Documentation at https://github.com/rafaelbiriba/auto_tag_version"
24
+ end
25
+ end
26
+
27
+ describe ".app" do
28
+ module Rails; def self.application; end; end
29
+
30
+ let :app do
31
+ "APP"
32
+ end
33
+
34
+ before do
35
+ allow(Rails).to receive_message_chain("application.class.parent_name").and_return(app)
36
+ end
37
+
38
+ it "should return the Rails app name" do
39
+ expect(subject.app).to eql app
40
+ end
41
+ end
42
+
43
+ describe ".version_file" do
44
+ it "should return the version filepath" do
45
+ expect(subject.version_file).to eql "config/initializers/app_version.rb"
46
+ end
47
+ end
48
+
49
+ describe ".create_version_file" do
50
+ let :file do
51
+ "spec_test_file"
52
+ end
53
+
54
+ before do
55
+ allow(subject).to receive(:version_file).and_return(file)
56
+ allow(subject).to receive(:content).and_return("test")
57
+ end
58
+
59
+ after do
60
+ FileUtils.rm file
61
+ end
62
+
63
+ it "should create the version file" do
64
+ subject.create_version_file
65
+ expect(`cat #{file}`).to eql "test"
66
+ end
67
+ end
68
+
69
+ describe ".commit_and_create_tag" do
70
+ before do
71
+ allow(subject).to receive(:version_file).and_return("test")
72
+ allow(subject).to receive(:tag).and_return("1.2.3")
73
+ end
74
+
75
+ it "should commit and create the git tag" do
76
+ git_msg = "git add test && git commit -m \"Bumping version 1.2.3\" && git tag 1.2.3"
77
+ expect(subject).to receive(:`).with(git_msg)
78
+ subject.commit_and_create_tag
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,80 @@
1
+ require "auto_tag_version"
2
+
3
+ RSpec.configure do |config|
4
+ # rspec-expectations config goes here. You can use an alternate
5
+ # assertion/expectation library such as wrong or the stdlib/minitest
6
+ # assertions if you prefer.
7
+ config.expect_with :rspec do |expectations|
8
+ # This option will default to `true` in RSpec 4. It makes the `description`
9
+ # and `failure_message` of custom matchers include text for helper methods
10
+ # defined using `chain`, e.g.:
11
+ # be_bigger_than(2).and_smaller_than(4).description
12
+ # # => "be bigger than 2 and smaller than 4"
13
+ # ...rather than:
14
+ # # => "be bigger than 2"
15
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16
+ end
17
+
18
+ # rspec-mocks config goes here. You can use an alternate test double
19
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
20
+ config.mock_with :rspec do |mocks|
21
+ # Prevents you from mocking or stubbing a method that does not exist on
22
+ # a real object. This is generally recommended, and will default to
23
+ # `true` in RSpec 4.
24
+ mocks.verify_partial_doubles = true
25
+ end
26
+
27
+ # The settings below are suggested to provide a good initial experience
28
+ # with RSpec, but feel free to customize to your heart's content.
29
+ =begin
30
+ # These two settings work together to allow you to limit a spec run
31
+ # to individual examples or groups you care about by tagging them with
32
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
33
+ # get run.
34
+ config.filter_run :focus
35
+ config.run_all_when_everything_filtered = true
36
+
37
+ # Allows RSpec to persist some state between runs in order to support
38
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
39
+ # you configure your source control system to ignore this file.
40
+ config.example_status_persistence_file_path = "spec/examples.txt"
41
+
42
+ # Limits the available syntax to the non-monkey patched syntax that is
43
+ # recommended. For more details, see:
44
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
45
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
46
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
47
+ config.disable_monkey_patching!
48
+
49
+ # This setting enables warnings. It's recommended, but in some cases may
50
+ # be too noisy due to issues in dependencies.
51
+ config.warnings = true
52
+
53
+ # Many RSpec users commonly either run the entire suite or an individual
54
+ # file, and it's useful to allow more verbose output when running an
55
+ # individual spec file.
56
+ if config.files_to_run.one?
57
+ # Use the documentation formatter for detailed output,
58
+ # unless a formatter has already been configured
59
+ # (e.g. via a command-line flag).
60
+ config.default_formatter = 'doc'
61
+ end
62
+
63
+ # Print the 10 slowest examples and example groups at the
64
+ # end of the spec run, to help surface which specs are running
65
+ # particularly slow.
66
+ config.profile_examples = 10
67
+
68
+ # Run specs in random order to surface order dependencies. If you find an
69
+ # order dependency and want to debug it, you can fix the order by providing
70
+ # the seed, which is printed after each run.
71
+ # --seed 1234
72
+ config.order = :random
73
+
74
+ # Seed global randomization in this process using the `--seed` CLI option.
75
+ # Setting this allows you to use `--seed` to deterministically reproduce
76
+ # test failures related to randomization by passing the same `--seed` value
77
+ # as the one that triggered the failure.
78
+ Kernel.srand config.seed
79
+ =end
80
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_tag_version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rafael Biriba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
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: 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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Generate auto tag
56
+ email:
57
+ - biribarj@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .rspec
63
+ - .ruby-gemset
64
+ - .ruby-version
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - README.md
68
+ - Rakefile
69
+ - auto_tag_version.gemspec
70
+ - lib/auto_tag_version.rb
71
+ - lib/auto_tag_version/railtie.rb
72
+ - lib/auto_tag_version/utils.rb
73
+ - lib/auto_tag_version/version.rb
74
+ - lib/tasks/autotag.rake
75
+ - spec/lib/auto_tag_version/utils_spec.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/rafaelbiriba/auto_tag_version
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Generate auto tag
101
+ test_files: []