new 0.0.6 → 0.0.7

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/.new +1 -1
  4. data/Gemfile.lock +25 -20
  5. data/Guardfile +6 -4
  6. data/README.md +9 -2
  7. data/doc/.git +1 -0
  8. data/doc/Gemfile.html +125 -0
  9. data/doc/Gemfile_lock.html +198 -0
  10. data/doc/Guardfile.html +134 -0
  11. data/doc/InterpolateSpec.html +116 -0
  12. data/doc/LICENSE_txt.html +132 -0
  13. data/doc/New/Cli.html +290 -0
  14. data/doc/New/Dsl.html +185 -0
  15. data/doc/New/Interpolate.html +238 -0
  16. data/doc/New/Project.html +171 -0
  17. data/doc/New/Task/CustomBarTask.html +154 -0
  18. data/doc/New/Task/FooTask.html +168 -0
  19. data/doc/New/Task/Gem.html +197 -0
  20. data/doc/New/Task/TaskSpec.html +168 -0
  21. data/doc/New/Task.html +380 -0
  22. data/doc/New/Template.html +234 -0
  23. data/doc/New/Version.html +277 -0
  24. data/doc/New.html +377 -0
  25. data/doc/Object.html +200 -0
  26. data/doc/README_md.html +292 -0
  27. data/doc/VersionSpec.html +116 -0
  28. data/doc/created.rid +47 -0
  29. data/doc/fonts/Lato-Light.ttf +0 -0
  30. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  31. data/doc/fonts/Lato-Regular.ttf +0 -0
  32. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  33. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  34. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  35. data/doc/fonts.css +167 -0
  36. data/doc/images/add.png +0 -0
  37. data/doc/images/arrow_up.png +0 -0
  38. data/doc/images/brick.png +0 -0
  39. data/doc/images/brick_link.png +0 -0
  40. data/doc/images/bug.png +0 -0
  41. data/doc/images/bullet_black.png +0 -0
  42. data/doc/images/bullet_toggle_minus.png +0 -0
  43. data/doc/images/bullet_toggle_plus.png +0 -0
  44. data/doc/images/date.png +0 -0
  45. data/doc/images/delete.png +0 -0
  46. data/doc/images/find.png +0 -0
  47. data/doc/images/loadingAnimation.gif +0 -0
  48. data/doc/images/macFFBgHack.png +0 -0
  49. data/doc/images/package.png +0 -0
  50. data/doc/images/page_green.png +0 -0
  51. data/doc/images/page_white_text.png +0 -0
  52. data/doc/images/page_white_width.png +0 -0
  53. data/doc/images/plugin.png +0 -0
  54. data/doc/images/ruby.png +0 -0
  55. data/doc/images/tag_blue.png +0 -0
  56. data/doc/images/tag_green.png +0 -0
  57. data/doc/images/transparent.png +0 -0
  58. data/doc/images/wrench.png +0 -0
  59. data/doc/images/wrench_orange.png +0 -0
  60. data/doc/images/zoom.png +0 -0
  61. data/doc/index.html +142 -0
  62. data/doc/js/darkfish.js +140 -0
  63. data/doc/js/jquery.js +18 -0
  64. data/doc/js/navigation.js +142 -0
  65. data/doc/js/search.js +109 -0
  66. data/doc/js/search_index.js +1 -0
  67. data/doc/js/searcher.js +228 -0
  68. data/doc/rdoc.css +580 -0
  69. data/doc/spec/fixtures/custom/templates/custom_bar_template/custom_bar_txt.html +110 -0
  70. data/doc/table_of_contents.html +324 -0
  71. data/doc/tasks/gem/README_md.html +150 -0
  72. data/doc/templates/js/Gemfile.html +147 -0
  73. data/doc/templates/js/Guardfile.html +117 -0
  74. data/doc/templates/js/lib/README_md.html +114 -0
  75. data/doc/templates/js/spec/spec_helper_js_coffee.html +110 -0
  76. data/doc/templates/js/spec/vendor/chai_js.html +3864 -0
  77. data/doc/templates/js/spec/vendor/sinon-chai_js.html +222 -0
  78. data/doc/templates/js/spec/vendor/sinon_js.html +4358 -0
  79. data/doc/templates/js/src/README_md.html +125 -0
  80. data/lib/new/task.rb +2 -4
  81. data/lib/new/template.rb +1 -1
  82. data/lib/new/version.rb +27 -19
  83. data/spec/fixtures/tasks/foo_task/Gemfile +5 -0
  84. data/spec/lib/new/version_spec.rb +10 -15
  85. data/spec/spec_helper.rb +22 -1
  86. data/tasks/gem/gem.rb +44 -8
  87. data/tasks/gem/gem_spec.rb +139 -0
  88. metadata +233 -3
@@ -0,0 +1,125 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>README - RDoc Documentation</title>
8
+
9
+ <link href="../../../fonts.css" rel="stylesheet">
10
+ <link href="../../../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../../../";
14
+ </script>
15
+
16
+ <script src="../../../js/jquery.js"></script>
17
+ <script src="../../../js/navigation.js"></script>
18
+ <script src="../../../js/search_index.js"></script>
19
+ <script src="../../../js/search.js"></script>
20
+ <script src="../../../js/searcher.js"></script>
21
+ <script src="../../../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="file">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../../../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../../../table_of_contents.html#pages">Pages</a>
34
+ <a href="../../../table_of_contents.html#classes">Classes</a>
35
+ <a href="../../../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+ <div class="nav-section">
58
+ <h3>Table of Contents</h3>
59
+
60
+ <ul class="link-list" role="directory">
61
+ <li><a href="#label-CHANGE+LOG">CHANGE LOG</a>
62
+ <li><a href="#label-0.0.1">0.0.1</a>
63
+ </ul>
64
+ </div>
65
+
66
+
67
+ <div id="project-metadata">
68
+ <div id="fileindex-section" class="nav-section">
69
+ <h3>Pages</h3>
70
+
71
+ <ul class="link-list">
72
+
73
+ <li><a href="../../../Gemfile.html">Gemfile</a>
74
+
75
+ <li><a href="../../../Gemfile_lock.html">Gemfile.lock</a>
76
+
77
+ <li><a href="../../../Guardfile.html">Guardfile</a>
78
+
79
+ <li><a href="../../../LICENSE_txt.html">LICENSE</a>
80
+
81
+ <li><a href="../../../README_md.html">README</a>
82
+
83
+ <li><a href="../../../spec/fixtures/custom/templates/custom_bar_template/custom_bar_txt.html">custom_bar</a>
84
+
85
+ <li><a href="../../../tasks/gem/README_md.html">README</a>
86
+
87
+ <li><a href="../../../templates/js/Gemfile.html">Gemfile</a>
88
+
89
+ <li><a href="../../../templates/js/Guardfile.html">Guardfile</a>
90
+
91
+ <li><a href="../../../templates/js/lib/README_md.html">README</a>
92
+
93
+ <li><a href="../../../templates/js/spec/spec_helper_js_coffee.html">spec_helper.js.coffee</a>
94
+
95
+ <li><a href="../../../templates/js/spec/vendor/chai_js.html">chai.js</a>
96
+
97
+ <li><a href="../../../templates/js/spec/vendor/sinon-chai_js.html">sinon-chai.js</a>
98
+
99
+ <li><a href="../../../templates/js/spec/vendor/sinon_js.html">sinon.js</a>
100
+
101
+ <li><a href="../../../templates/js/src/README_md.html">README</a>
102
+
103
+ </ul>
104
+ </div>
105
+
106
+ </div>
107
+ </nav>
108
+
109
+ <main role="main" aria-label="Page templates/js/src/README.md">
110
+
111
+ <h4 id="label-CHANGE+LOG">CHANGE LOG<span><a href="#label-CHANGE+LOG">&para;</a> <a href="#documentation">&uarr;</a></span></h4>
112
+
113
+ <h6 id="label-0.0.1">0.0.1<span><a href="#label-0.0.1">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
114
+
115
+ <p>*</p>
116
+ </main>
117
+
118
+
119
+
120
+ <footer id="validator-badges" role="contentinfo">
121
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
122
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
123
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
124
+ </footer>
125
+
data/lib/new/task.rb CHANGED
@@ -20,13 +20,11 @@ class New::Task
20
20
  #
21
21
  def project_options
22
22
  custom_options = New.custom_config
23
- project_options = @project_config
24
-
25
- all_options = custom_options.deep_merge(project_options)
23
+ all_options = custom_options.deep_merge(@project_config)
26
24
 
27
25
  # Groom tasks (prevent tasks from the custom config from polluting the project config)
28
26
  all_options[:tasks].each_key do |task|
29
- all_options[:tasks].delete(task) unless project_options[:tasks].has_key?(task)
27
+ all_options[:tasks].delete(task) unless @project_config[:tasks].has_key?(task)
30
28
  end
31
29
 
32
30
  @project_options ||= all_options
data/lib/new/template.rb CHANGED
@@ -7,7 +7,7 @@ class New::Template
7
7
  #
8
8
  CUSTOM_CONFIG_TEMPLATE = {
9
9
  license: '[LICENSE]',
10
- version: '[VERSION]',
10
+ version: '0.0.0',
11
11
  developer: {
12
12
  name: '[NAME]',
13
13
  email: '[EMAIL]'
data/lib/new/version.rb CHANGED
@@ -1,22 +1,34 @@
1
1
  module New::Version
2
2
  require 'semantic'
3
3
 
4
- def version= string
5
- @version ||= begin
6
- Semantic::Version.new string
7
- rescue
8
- New.say "#{string} is not a semantic version. Use format `1.2.3`", type: :fail
9
- exit
4
+ def version; @version; end
5
+
6
+ def get_part
7
+ New.say " Current Version: #{version}", type: :success
8
+ New.say " Specify which part to bump: [#{'Mmp'.green}] (#{'M'.green}ajor / #{'m'.green}inor / #{'p'.green}atch)"
9
+ part = STDIN.gets.chomp!
10
+
11
+ case part
12
+ when 'M'
13
+ :major
14
+ when 'm'
15
+ :minor
16
+ when 'p'
17
+ :patch
10
18
  end
11
19
  end
12
- def version; @version; end
13
20
 
14
- def bump_version part
21
+ def bump_version current_version, part
22
+ get_version current_version
23
+
15
24
  case part
16
25
  when :major
17
26
  version.major += 1
27
+ version.minor = 0
28
+ version.patch = 0
18
29
  when :minor
19
30
  version.minor += 1
31
+ version.patch = 0
20
32
  when :patch
21
33
  version.patch += 1
22
34
  end
@@ -24,18 +36,14 @@ module New::Version
24
36
  version
25
37
  end
26
38
 
27
- def get_part
28
- New.say " Current Version: #{version}", type: :success
29
- New.say " Specify which part to bump: [#{'Mmp'.green}] (#{'M'.green}ajor / #{'m'.green}inor / #{'p'.green}atch)"
30
- part = STDIN.gets.chomp!
39
+ private
31
40
 
32
- case part
33
- when 'M'
34
- :major
35
- when 'm'
36
- :minor
37
- when 'p'
38
- :patch
41
+ def get_version string
42
+ @version ||= begin
43
+ Semantic::Version.new string
44
+ rescue
45
+ New.say "#{string} is not a semantic version. Use format `1.2.3`", type: :fail
46
+ exit
39
47
  end
40
48
  end
41
49
  end
@@ -0,0 +1,5 @@
1
+ gem 'foo', '~> 1.2.3'
2
+
3
+ group :development do
4
+ gem 'bar'
5
+ end
@@ -7,22 +7,17 @@ end
7
7
  describe New::Version do
8
8
  let(:version){ VersionSpec.new }
9
9
 
10
- before do
11
- version.version = '1.2.3'
12
- end
13
-
14
- it 'should set a version' do
15
- expect(version.version.to_s).to eq '1.2.3'
16
- end
17
-
18
- it 'should bump the version' do
19
- version.bump_version :major
20
- expect(version.version.to_s).to eq '2.2.3'
10
+ describe '#bump_version' do
11
+ it 'should bump the major version' do
12
+ expect(version.bump_version('1.2.3', :major).to_s).to eq '2.0.0'
13
+ end
21
14
 
22
- version.bump_version :minor
23
- expect(version.version.to_s).to eq '2.3.3'
15
+ it 'should bump the minor version' do
16
+ expect(version.bump_version('1.2.3', :minor).to_s).to eq '1.3.0'
17
+ end
24
18
 
25
- version.bump_version :patch
26
- expect(version.version.to_s).to eq '2.3.4'
19
+ it 'should bump the patch version' do
20
+ expect(version.bump_version('1.2.3', :patch).to_s).to eq '1.2.4'
21
+ end
27
22
  end
28
23
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  $: << File.expand_path('../../lib', __FILE__)
2
- $: << File.expand_path('../fixtures', __FILE__)
3
2
  require 'new'
3
+ $: << File.expand_path('../../tasks', __FILE__)
4
+ $: << File.expand_path('../fixtures', __FILE__)
5
+ $: << File.expand_path('tasks', New::CUSTOM_DIR)
4
6
 
5
7
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
6
8
  RSpec.configure do |config|
@@ -24,3 +26,22 @@ end
24
26
  def root *paths
25
27
  paths.unshift(File.expand_path('../../', __FILE__)).compact.join '/'
26
28
  end
29
+
30
+ def require_task task
31
+ require "#{task}/#{task}"
32
+ end
33
+
34
+ def new_task task, options = {}
35
+ task_class = "New::Task::#{task.to_s.classify}".constantize
36
+
37
+ task_class.any_instance.stub(:get_part).and_return(:patch)
38
+ task_class.any_instance.stub(:run)
39
+
40
+ task_hash = {}
41
+ task_hash[task] = {}
42
+ task_options = {
43
+ tasks: task_hash
44
+ }.merge(options)
45
+
46
+ task_class.new task_options
47
+ end
data/tasks/gem/gem.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'bundler'
1
2
  require 'rake'
2
3
  require 'yaml'
3
4
 
@@ -6,6 +7,7 @@ class New::Task::Gem < New::Task
6
7
  include New::Version
7
8
 
8
9
  GLOB_ATTRIBUTES = [:files, :test_files, :extra_rdoc_files]
10
+ GEMFILE = File.expand_path(File.join(Dir.pwd, 'Gemfile'))
9
11
  OPTIONS = {
10
12
  gemspec: {
11
13
  summary: "A short summary of this gem's description. Displayed in `gem list -d`",
@@ -27,16 +29,15 @@ class New::Task::Gem < New::Task
27
29
  private
28
30
 
29
31
  def set_version
30
- # set version
31
- self.version = project_options[:version]
32
-
33
32
  # bump version
34
- bump_version get_part
33
+ version = bump_version(project_options[:version], get_part).to_s
35
34
 
36
35
  # set new version to config
37
- project_options[:version] = version.to_s
36
+ project_options[:version] = version
38
37
  end
39
38
 
39
+ # Check that any glob pattern attributes match existing files
40
+ #
40
41
  def validate_files
41
42
  GLOB_ATTRIBUTES.each do |file_attr|
42
43
  next if @gemspec[file_attr].nil?
@@ -60,7 +61,7 @@ private
60
61
  end
61
62
 
62
63
  def render_gemspec_options
63
- string = []
64
+ array = []
64
65
 
65
66
  # set defaults
66
67
  @gemspec[:date] = Date.today.to_s
@@ -86,10 +87,45 @@ private
86
87
  else v
87
88
  end
88
89
 
89
- string << " s.#{k} = #{val}"
90
+ array << " s.#{k} = #{val}"
91
+ end
92
+
93
+ array += extract_gem_dependencies
94
+
95
+ project_options[:gemspec_string] = array.join("\n")
96
+ end
97
+
98
+ # Extract dependencies based on the Gemfile to be used in the gemspec
99
+ #
100
+ def extract_gem_dependencies
101
+ b = Bundler::Dsl.new
102
+ b.eval_gemfile(GEMFILE)
103
+
104
+ array = []
105
+ runtime = []
106
+ development = []
107
+
108
+ # loop through the required gems and find default and development gems
109
+ b.dependencies.each do |g|
110
+ groups = g.groups
111
+ data = {
112
+ name: g.name,
113
+ requirements: g.requirements_list.map{ |r| "'#{r}'" }.join(',')
114
+ }
115
+
116
+ runtime << data if groups.include? :default
117
+ development << data if groups.include? :development
118
+ end
119
+
120
+ # create .gemspec friendly string of requirements
121
+ runtime.each do |r|
122
+ array << " s.add_runtime_dependency '#{r[:name]}', #{r[:requirements]}"
123
+ end
124
+ development.each do |r|
125
+ array << " s.add_development_dependency '#{r[:name]}', #{r[:requirements]}"
90
126
  end
91
127
 
92
- project_options[:gemspec_string] = string.join("\n")
128
+ return array
93
129
  end
94
130
 
95
131
  def write_gemspec
@@ -0,0 +1,139 @@
1
+ require 'spec_helper'
2
+ require_task :gem
3
+
4
+ describe New::Task::Gem do
5
+ before do
6
+ stub_const 'New::CONFIG_FILE', New::CONFIG_FILE
7
+ stub_const 'New::Task::Gem::GLOB_ATTRIBUTES', [:foo_files]
8
+ @gem = new_task :gem, { version: '1.2.3' }
9
+ @pwd = Dir.pwd
10
+ @tmp_dir = Dir.mktmpdir
11
+
12
+ Dir.chdir @tmp_dir
13
+ end
14
+
15
+ after do
16
+ New::Task::Gem.any_instance.unstub(:run)
17
+ Dir.chdir @pwd
18
+ end
19
+
20
+ describe '#set_version' do
21
+ before do
22
+ @gem.send(:set_version)
23
+ end
24
+
25
+ it 'should set the version for project options' do
26
+ expect(@gem.project_options[:version]).to eq '1.2.4'
27
+ end
28
+ end
29
+
30
+ describe '#validate_files' do
31
+ before do
32
+ # temporarily change the current directory to the gem task folder to test for valid files
33
+ Dir.chdir File.dirname(__FILE__)
34
+
35
+ @gem.instance_variable_set(:@gemspec, { foo_files: ['*.rb', '*.md'] })
36
+ @gem.send(:validate_files)
37
+ end
38
+
39
+ after do
40
+ # go back to the original root dir
41
+ Dir.chdir @tmp_dir
42
+ end
43
+
44
+ it 'should replace the file_attr array of globs with an array of files' do
45
+ files = @gem.instance_variable_get(:@gemspec)[:foo_files]
46
+ expect(files.all?{ |f| files.include? f }).to be_true
47
+ end
48
+ end
49
+
50
+ describe '#render_gemspec_options' do
51
+ before do
52
+ @gem.stub(:extract_gem_dependencies).and_return(['s.extract_gem_dependencies'])
53
+ @gem.instance_variable_set(:@gemspec, {})
54
+ @gem.send(:render_gemspec_options)
55
+ end
56
+
57
+ after do
58
+ @gem.unstub(:extract_gem_dependencies)
59
+ end
60
+
61
+ it 'should create the gemspec_string option' do
62
+ gemspec_string = @gem.project_options[:gemspec_string]
63
+ expect(gemspec_string).to include "s.author = 'Foo Bar'"
64
+ expect(gemspec_string).to include "s.license = 'MIT'"
65
+ expect(gemspec_string).to include "s.extract_gem_dependencies"
66
+ end
67
+
68
+ context 'when plurals are set' do
69
+ before do
70
+ @gem.instance_variable_set(:@gemspec, {
71
+ authors: ['Foo Author'],
72
+ licenses: ['Foo License'],
73
+ })
74
+ @gem.send(:render_gemspec_options)
75
+ end
76
+
77
+ it 'should replace the singulars' do
78
+ expect(@gem.project_options[:gemspec_string]).to include 's.authors = ["Foo Author"]'
79
+ expect(@gem.project_options[:gemspec_string]).to_not include 's.author = '
80
+ expect(@gem.project_options[:gemspec_string]).to include 's.licenses = ["Foo License"]'
81
+ expect(@gem.project_options[:gemspec_string]).to_not include 's.license = '
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#extract_gem_dependencies' do
87
+ before do
88
+ stub_const 'New::Task::Gem::GEMFILE', root('spec', 'fixtures', 'tasks', 'foo_task', 'Gemfile')
89
+ end
90
+
91
+ it 'should set dependencies' do
92
+ gem_dependencies = @gem.send(:extract_gem_dependencies)
93
+ expect(gem_dependencies).to include " s.add_runtime_dependency 'foo', '~> 1.2.3'"
94
+ expect(gem_dependencies).to include " s.add_development_dependency 'bar', '>= 0'"
95
+ end
96
+ end
97
+
98
+ describe '#write_gemspec' do
99
+ before do
100
+ @gem.stub(:project_options).and_return({ gemspec_string: 'foo' })
101
+ @gem.send(:write_gemspec)
102
+ end
103
+
104
+ after do
105
+ @gem.unstub(:project_options)
106
+ end
107
+
108
+ it 'should write a gemspec file' do
109
+ expect(File.exist?('.gemspec')).to be_true
110
+ end
111
+
112
+ it 'should be a valid gemspec file' do
113
+ gemspec = File.read('.gemspec')
114
+ expect(gemspec).to include 'Gem::Specification.new'
115
+ expect(gemspec).to include 'foo'
116
+ end
117
+ end
118
+
119
+ describe '#write_config' do
120
+ before do
121
+ @gem.stub(:project_options).and_return({
122
+ gemspec_string: 'foo',
123
+ foo_files: 'foo',
124
+ bar: 'bar'
125
+ })
126
+ @gem.send(:write_config)
127
+ end
128
+
129
+ after do
130
+ @gem.unstub(:project_options)
131
+ end
132
+
133
+ it 'should update the config file' do
134
+ config = File.read(New::CONFIG_FILE)
135
+ expect(config).to_not include 'foo'
136
+ expect(config).to include 'bar: bar'
137
+ end
138
+ end
139
+ end