js_rake_tasks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/js_rake_tasks.rb +73 -0
  2. metadata +78 -0
@@ -0,0 +1,73 @@
1
+ include Rake::DSL if defined?(Rake::DSL)
2
+
3
+ namespace 'coffee' do
4
+ task "compile" do
5
+ `coffee --compile --output dist/ src/`
6
+ end
7
+ end
8
+
9
+ namespace "js" do
10
+ namespace "version" do
11
+ namespace "bump" do
12
+ task "major", :compile do
13
+ update_version { |v| v.major += 1 }
14
+ end
15
+
16
+ task "minor", :compile do
17
+ update_version { |v| v.minor += 1 }
18
+ end
19
+
20
+ task "patch", :compile do
21
+ update_version { |v| v.patch += 1 }
22
+ end
23
+
24
+ def update_version &blk
25
+ git = VersionsGit.new
26
+ fail("Oops! Can't bump a version with a dirty repo!") unless git.clean?
27
+ version = update_package_json(&blk)
28
+ tag_project(git,version)
29
+ end
30
+
31
+ def tag_project(git, version)
32
+ git.tag(version)
33
+ git.push
34
+ end
35
+
36
+ def update_package_json
37
+ require 'json'
38
+ require 'semver'
39
+
40
+ package = JSON.parse(File.read("package.json"))
41
+ version = SemVer.new(*package["version"].split(".").map(&:to_i))
42
+ yield(version)
43
+ package["version"] = version.format('%M.%m.%p%s')
44
+ File.open('package.json', 'w') do |f|
45
+ f.puts JSON.pretty_generate(package)
46
+ end
47
+ package["version"]
48
+ end
49
+
50
+ class VersionsGit
51
+ def initialize
52
+ require 'git'
53
+ @g = Git.open(Dir.pwd)
54
+ end
55
+
56
+ def tag(version)
57
+ @g.add('package.json')
58
+ @g.commit("Bumping version to #{version}")
59
+ @g.add_tag(version)
60
+ end
61
+
62
+ def push
63
+ @g.push("origin",@g.current_branch,true)
64
+ end
65
+
66
+ def clean?
67
+ [@g.status.deleted,@g.status.added,@g.status.changed].all? { |o| o.size == 0 }
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: js_rake_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Justin Searls
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-01-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json_pure
16
+ requirement: &903689760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *903689760
25
+ - !ruby/object:Gem::Dependency
26
+ name: semver
27
+ requirement: &903689530 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *903689530
36
+ - !ruby/object:Gem::Dependency
37
+ name: git
38
+ requirement: &903689300 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.5
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *903689300
47
+ description: Rake tasks for little JavaScript projects
48
+ email: searls@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/js_rake_tasks.rb
54
+ homepage: http://github.com/searls/js_rake_tasks
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Provides a few tasks for managing CoffeeScript/JavaScript projects
78
+ test_files: []