auto_tag_version 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3daed2fb331a8613c937b4212eddf3bb32b13faa
4
- data.tar.gz: 85835ecd6c13528d2981bd6495cabdfb264d70b6
3
+ metadata.gz: e41f580e63a00ffd61c7d7b340f015f5a6d84241
4
+ data.tar.gz: 6bebe7e6d370d207877dc15dffd14de581ff67fa
5
5
  SHA512:
6
- metadata.gz: 144b49f4f80e57022a3d3e7f62addd8c70114823589f4ebfb54fd2b3726317f841121eb0d984c3614183be80ae793d56972759412d11dcc9102ed6eca5fe08b3
7
- data.tar.gz: e4b6d40856523e35ba7b6ce5996cff7e1c677d2034bec23d5f867ed9d3e8d261e0e52a7232c88b76764760bed726c8ad640ddd3a3b42ddc4bc56ec6d69e10ead
6
+ metadata.gz: 156d514ebad28258cd565abd14bf1e049fcc4dd7635b8d36a42114d9be28163d67e7d873b3a01b91655ceeb6561fbf7ac4b6126eb2db356540bfc1f8e1681f38
7
+ data.tar.gz: ecaf8601a425649e0d390eabe497be6592ff8232926c59623b867eb0f9fce65ccdadc4a235d7940d5a4e2c7bf7c9a8175b2e00d1e7fed93ab0a7582424ee1f1e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- auto_tag_version (1.0.0)
4
+ auto_tag_version (1.1.0)
5
5
  railties
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,7 +4,7 @@ Create/Update the application version file of your Rails app and automatically c
4
4
 
5
5
  ## Prerequisite
6
6
 
7
- - For now, only Rails application (Tested Rails 3 and 4)
7
+ - Rails application
8
8
  - *Gems support comming soon!*
9
9
 
10
10
  ## Installation
@@ -6,12 +6,20 @@ module AutoTagVersion
6
6
  commit_and_create_tag
7
7
  end
8
8
 
9
+ def print_last_tag_information
10
+ if last_git_tag == tag
11
+ puts "Everything OK! Last git tag created: #{last_git_tag}"
12
+ else
13
+ puts "Something goes wrong with the tag creation. Check your git log."
14
+ end
15
+ end
16
+
9
17
  private
10
18
  attr_reader :tag
11
19
 
12
20
  def content
13
- content = "module #{app}; VERSION = '#{tag}'; end\n"
14
- content += "# This file is created automatically by auto_tag_version gem\n"
21
+ content = "module #{app}; VERSION = '#{tag}'; end\n\n"
22
+ content += "# This file was created automatically by auto_tag_version gem\n"
15
23
  content += "# Documentation at https://github.com/rafaelbiriba/auto_tag_version"
16
24
  end
17
25
 
@@ -30,5 +38,9 @@ module AutoTagVersion
30
38
  def commit_and_create_tag
31
39
  `git add #{version_file} && git commit -m "Bumping version #{tag}" && git tag #{tag}`
32
40
  end
41
+
42
+ def last_git_tag
43
+ `git describe --abbrev=0 --tags`.strip
44
+ end
33
45
  end
34
46
  end
@@ -1,3 +1,3 @@
1
1
  module AutoTagVersion
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,10 +1,13 @@
1
1
  desc "Create/Update the APP VERSION and create the git tag. USAGE: rake autotag TAG=0.0.0"
2
2
  task :autotag do
3
+ tag = ENV["TAG"]
3
4
  if !defined?(Rails)
4
5
  puts "Rails app not found!"
5
- elsif ENV["TAG"].blank?
6
+ elsif tag.blank?
6
7
  puts "TAG not found! USAGE: rake autotag TAG=0.0.0"
7
8
  else
8
- AutoTagVersion.tag!(ENV["TAG"])
9
+ puts "Creating #{tag} tag..."
10
+ AutoTagVersion.tag!(tag)
11
+ AutoTagVersion.print_last_tag_information
9
12
  end
10
13
  end
@@ -6,21 +6,28 @@ describe AutoTagVersion do
6
6
  end
7
7
 
8
8
  module Rails; def self.application; end; end
9
- module APP; end;
9
+ module APP; end
10
10
 
11
- let(:tag_version) { "1.2.3" }
11
+ let(:tag_version) { "#{rand(9)}.#{rand(9)}.#{rand(9)}" }
12
12
  let(:app) { APP }
13
- let(:app_version_path) { "config/initializers/app_version.rb" }
13
+ let(:app_version_file) { "config/initializers/app_version.rb" }
14
+ let(:git_add_cmd) { "git add #{app_version_file} && git commit -m \"Bumping version #{tag_version}\" && git tag #{tag_version}" }
15
+
14
16
 
15
17
  before do
16
18
  allow(Rails).to receive_message_chain("application.class.parent_name").and_return(app.to_s)
19
+ allow(subject).to receive(:`).with(git_add_cmd)
20
+ end
21
+
22
+ after do
23
+ FileUtils.rm(app_version_file) if File.exist?(app_version_file)
17
24
  end
18
25
 
19
26
  describe ".tag!" do
20
27
  context "VERSION variable available" do
21
28
  before do
22
29
  subject.tag!(tag_version)
23
- load(app_version_path)
30
+ load(app_version_file)
24
31
  end
25
32
 
26
33
  it "should save the correct tag version" do
@@ -29,12 +36,28 @@ describe AutoTagVersion do
29
36
  end
30
37
 
31
38
  context "git integration" do
32
- let(:git_msg) { "git add #{app_version_path} && git commit -m \"Bumping version #{tag_version}\" && git tag #{tag_version}" }
33
-
34
39
  it "should run the correct git command" do
35
- expect(subject).to receive(:`).with(git_msg)
40
+ expect(subject).to receive(:`).with(git_add_cmd)
36
41
  subject.tag!(tag_version)
37
42
  end
38
43
  end
39
44
  end
45
+
46
+ describe ".print_last_tag_information" do
47
+ let(:git_tags_cmd) { "git describe --abbrev=0 --tags" }
48
+
49
+ before do
50
+ allow(subject).to receive(:`).with(git_tags_cmd).and_return(tag_version)
51
+ subject.tag!(tag_version)
52
+ end
53
+
54
+ it "should print successful message" do
55
+ expect { subject.print_last_tag_information }.to output("Everything OK! Last git tag created: #{tag_version}\n").to_stdout
56
+ end
57
+
58
+ it "should print successful message" do
59
+ allow(subject).to receive(:`).with(git_tags_cmd).and_return("test.0.1")
60
+ expect { subject.print_last_tag_information }.to output("Something goes wrong with the tag creation. Check your git log.\n").to_stdout
61
+ end
62
+ end
40
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_tag_version
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Biriba
@@ -81,7 +81,6 @@ files:
81
81
  - README.md
82
82
  - Rakefile
83
83
  - auto_tag_version.gemspec
84
- - config/initializers/app_version.rb
85
84
  - lib/auto_tag_version.rb
86
85
  - lib/auto_tag_version/railtie.rb
87
86
  - lib/auto_tag_version/utils.rb