new 0.1.1 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +13 -5
  2. data/bin/new +0 -2
  3. data/lib/new.rb +125 -52
  4. data/lib/new/cli.rb +514 -67
  5. data/lib/new/source.rb +110 -0
  6. data/lib/new/task.rb +67 -24
  7. data/lib/new/validation.rb +191 -0
  8. metadata +75 -132
  9. data/.gitignore +0 -6
  10. data/.new +0 -23
  11. data/.rspec +0 -2
  12. data/Gemfile +0 -16
  13. data/Gemfile.lock +0 -82
  14. data/Guardfile +0 -16
  15. data/LICENSE.txt +0 -22
  16. data/README.md +0 -128
  17. data/lib/new/core.rb +0 -7
  18. data/lib/new/dsl.rb +0 -42
  19. data/lib/new/interpolate.rb +0 -106
  20. data/lib/new/project.rb +0 -34
  21. data/lib/new/template.rb +0 -67
  22. data/lib/new/version.rb +0 -54
  23. data/spec/fixtures/custom/.new +0 -16
  24. data/spec/fixtures/custom/tasks/custom_bar_task/custom_bar_task.rb +0 -3
  25. data/spec/fixtures/custom/templates/custom_bar_template/.new +0 -3
  26. data/spec/fixtures/custom/templates/custom_bar_template/custom_bar.txt +0 -0
  27. data/spec/fixtures/project/.new +0 -4
  28. data/spec/fixtures/project/.new_cli_release_spec +0 -2
  29. data/spec/fixtures/tasks/custom_bar_task/custom_bar_task.rb +0 -1
  30. data/spec/fixtures/tasks/foo_task/Gemfile +0 -5
  31. data/spec/fixtures/tasks/foo_task/foo_task.rb +0 -7
  32. data/spec/fixtures/templates/custom_bar_template/.gitkeep +0 -0
  33. data/spec/fixtures/templates/foo_template/.new +0 -1
  34. data/spec/fixtures/templates/foo_template/[FOO.BAR].txt.erb +0 -1
  35. data/spec/fixtures/templates/foo_template/nested_[FOO.BAR]/foo.txt.erb +0 -1
  36. data/spec/lib/new/cli_spec.rb +0 -107
  37. data/spec/lib/new/interpolate_spec.rb +0 -43
  38. data/spec/lib/new/project_spec.rb +0 -33
  39. data/spec/lib/new/task_spec.rb +0 -39
  40. data/spec/lib/new/template_spec.rb +0 -59
  41. data/spec/lib/new/version_spec.rb +0 -26
  42. data/spec/lib/new_spec.rb +0 -19
  43. data/spec/spec_helper.rb +0 -46
  44. data/tasks/gem/.gemspec.erb +0 -4
  45. data/tasks/gem/README.md +0 -36
  46. data/tasks/gem/gem.rb +0 -170
  47. data/tasks/gem/gem_spec.rb +0 -138
  48. data/templates/js/.bowerrc +0 -3
  49. data/templates/js/.gitignore +0 -3
  50. data/templates/js/.new.erb +0 -11
  51. data/templates/js/CHANGELOG.md +0 -3
  52. data/templates/js/Gemfile +0 -2
  53. data/templates/js/Guardfile +0 -7
  54. data/templates/js/LICENSE-MIT.erb +0 -22
  55. data/templates/js/README.md.erb +0 -41
  56. data/templates/js/bower.json.erb +0 -11
  57. data/templates/js/demo/[PROJECT.FILENAME]_demo.coffee +0 -0
  58. data/templates/js/demo/[PROJECT.FILENAME]_demo.sass +0 -0
  59. data/templates/js/demo/index.html.erb +0 -12
  60. data/templates/js/lib/README.md +0 -2
  61. data/templates/js/package.json +0 -5
  62. data/templates/js/spec/[PROJECT.FILENAME]_spec.coffee.erb +0 -1
  63. data/templates/js/spec/[PROJECT.FILENAME]_spec.sass +0 -0
  64. data/templates/js/spec/index.html.erb +0 -35
  65. data/templates/js/src/[PROJECT.FILENAME].coffee.erb +0 -18
  66. data/templates/js/src/[PROJECT.FILENAME].sass +0 -0
  67. data/templates/js/testem.yml +0 -23
  68. data/templates/js/yuyi_menu +0 -7
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .DS_Store
2
- .bundle
3
- .tmp
4
- pkg
5
- tmp
6
- *.gem
data/.new DELETED
@@ -1,23 +0,0 @@
1
- ---
2
- license: MIT
3
- developer:
4
- name: Ryan Brewster
5
- email: brewster1134@gmail.com
6
- github:
7
- username: brewster1134
8
- tasks:
9
- gem:
10
- gemspec:
11
- summary: A Quick & Custom Project Creation & Release Tool
12
- description: With custom templates and tasks, quickly create a new project and
13
- release it to the world.
14
- homepage: https://github.com/brewster1134/new
15
- executables:
16
- - new
17
- bindir: bin
18
- test_files:
19
- - spec/**/*.rb
20
- version: 0.1.1
21
- project:
22
- name: new
23
- type: js
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activesupport', '~> 4.0'
4
- gem 'colorize'
5
- gem 'rake'
6
- gem 'recursive-open-struct'
7
- gem 'semantic'
8
- gem 'thor'
9
-
10
- group :development do
11
- gem 'guard'
12
- gem 'guard-bundler'
13
- gem 'guard-rspec'
14
- gem 'rspec'
15
- gem 'terminal-notifier-guard'
16
- end
data/Gemfile.lock DELETED
@@ -1,82 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- activesupport (4.1.4)
5
- i18n (~> 0.6, >= 0.6.9)
6
- json (~> 1.7, >= 1.7.7)
7
- minitest (~> 5.1)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 1.1)
10
- celluloid (0.15.2)
11
- timers (~> 1.1.0)
12
- coderay (1.1.0)
13
- colorize (0.7.3)
14
- diff-lcs (1.2.5)
15
- ffi (1.9.3)
16
- formatador (0.2.5)
17
- guard (2.6.1)
18
- formatador (>= 0.2.4)
19
- listen (~> 2.7)
20
- lumberjack (~> 1.0)
21
- pry (>= 0.9.12)
22
- thor (>= 0.18.1)
23
- guard-bundler (2.0.0)
24
- bundler (~> 1.0)
25
- guard (~> 2.2)
26
- guard-rspec (4.3.1)
27
- guard (~> 2.1)
28
- rspec (>= 2.14, < 4.0)
29
- i18n (0.6.11)
30
- json (1.8.1)
31
- listen (2.7.9)
32
- celluloid (>= 0.15.2)
33
- rb-fsevent (>= 0.9.3)
34
- rb-inotify (>= 0.9)
35
- lumberjack (1.0.9)
36
- method_source (0.8.2)
37
- minitest (5.4.0)
38
- pry (0.10.0)
39
- coderay (~> 1.1.0)
40
- method_source (~> 0.8.1)
41
- slop (~> 3.4)
42
- rake (10.3.2)
43
- rb-fsevent (0.9.4)
44
- rb-inotify (0.9.5)
45
- ffi (>= 0.5.0)
46
- recursive-open-struct (0.5.0)
47
- rspec (3.0.0)
48
- rspec-core (~> 3.0.0)
49
- rspec-expectations (~> 3.0.0)
50
- rspec-mocks (~> 3.0.0)
51
- rspec-core (3.0.3)
52
- rspec-support (~> 3.0.0)
53
- rspec-expectations (3.0.3)
54
- diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.0.0)
56
- rspec-mocks (3.0.3)
57
- rspec-support (~> 3.0.0)
58
- rspec-support (3.0.3)
59
- semantic (1.3.0)
60
- slop (3.6.0)
61
- terminal-notifier-guard (1.5.3)
62
- thor (0.19.1)
63
- thread_safe (0.3.4)
64
- timers (1.1.0)
65
- tzinfo (1.2.1)
66
- thread_safe (~> 0.1)
67
-
68
- PLATFORMS
69
- ruby
70
-
71
- DEPENDENCIES
72
- activesupport (~> 4.0)
73
- colorize
74
- guard
75
- guard-bundler
76
- guard-rspec
77
- rake
78
- recursive-open-struct
79
- rspec
80
- semantic
81
- terminal-notifier-guard
82
- thor
data/Guardfile DELETED
@@ -1,16 +0,0 @@
1
- # More info at https://github.com/guard/guard#readme
2
-
3
- notification :terminal_notifier, subtitle: 'ruby.gems.new'
4
-
5
- guard :bundler do
6
- watch('Gemfile')
7
- end
8
-
9
- guard :rspec, all_after_pass: true, all_on_start: true, cmd: 'bundle exec rspec spec tasks' do
10
- watch(%r{^spec/.+_spec\.rb$})
11
- watch(%r{^tasks/.+_spec\.rb$})
12
- watch(%r{^tasks/(.+[^_spec])\.rb$}) { |m| "tasks/#{m[1]}_spec.rb" }
13
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
- watch('spec/spec_helper.rb') { 'spec' }
15
- watch('.rspec') { 'spec' }
16
- end
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Ryan Brewster
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,128 +0,0 @@
1
- # new
2
- ###### install
3
- ```shell
4
- gem install new
5
- new init
6
- ```
7
-
8
- ###### Create a new project
9
- ```shell
10
- new [TEMPLATE] [NAME]
11
- ```
12
-
13
- ###### Release a new version
14
- ```shell
15
- new release
16
- ```
17
-
18
- #### Templates
19
- Templates represent a boilerplate directory & file structure preconfigured for a given project type. _(eg js, ruby, gem, rails, etc.)_
20
-
21
- #### Tasks
22
- Tasks represent a process associated with releasing new code. Tasks are run in order they are listed in the project `.new` configuration file.
23
-
24
- #### Local Config/Templates/Tasks
25
- After running `new init`, you will have `.new` folder in your home directory. This directory contains:
26
-
27
- * `.new` local configuration file
28
- * `tasks` directory for custom tasks
29
- * `templates` directory for custom templates
30
-
31
- Copy or create custom templates & tasks in these folders. They will take precendence over the default templates included with the gem.
32
-
33
- **Make sure to edit your local configuration file!**
34
-
35
- ```yaml
36
- # ~/.new/.new
37
-
38
- license: MIT
39
- developer:
40
- name: Foo Bar
41
- email: foo@bar.com
42
- templates:
43
- foo_template:
44
- custom: option
45
- tasks:
46
- github:
47
- username: foouser
48
- ```
49
-
50
-
51
- #### Custom Templates
52
- * The directory name will be used for the template name.
53
- * Templates can have a `.new` file in the root of the folder. These values can be accessed through interpolation.
54
-
55
- ```yaml
56
- # ~/.new/templates/foo_template/.new
57
-
58
- foo: bar
59
- tasks:
60
- foo_task:
61
- bar_task:
62
- baz: 'baz'
63
- ```
64
-
65
- _Note: the tasks are followed by a colon `:` whether they have options or not._
66
-
67
- ###### Interpolation
68
- Use ERB template syntax in your files to interpolate template options. Make sure to add `.erb` to the end of the filename.
69
-
70
- You can also access any custom values set in your local configuration file.
71
-
72
- ```erb
73
- <%# ~/.new/templates/foo_template/foo.txt.erb %>
74
-
75
- <%= license %>
76
- <%= developer.name %>
77
- <%= developer.email %>
78
- <%= type %>
79
- <%= project.name %>
80
- <%= foo %>
81
- <%= tasks.bar_task.baz %>
82
- ```
83
-
84
- You can also interpolate directory and filenames using the syntax `foo_[DEVELOPER.NAME].txt`
85
-
86
- _Note using the dot notation to access nested attributes._
87
-
88
- #### Custom Tasks
89
- * The directory name will be used for the task name
90
- * A `.rb` file must be included in the directory with the same name
91
- * The `.rb` file must contain a class of `New::Task::FooTask` and inherit from `New::Task`
92
- * The `.rb` file must have a standard ruby `run` method that will run when a project is released.
93
- * A Task can have an `OPTIONS` constant with default options needed for the task to run. These can be further customized in the project or local configuration `.new` file
94
-
95
- ```ruby
96
- # ~/.new/tasks/foo_task/foo_task.rb
97
-
98
- class New::Task::FooTask < New::Test
99
- include New::Interpolate # if you need to interpolate files
100
- include New::version # if you need to set & manage a semantic version
101
-
102
- # defaults for required options
103
- OPTION = {
104
- foo: 'bar'
105
- }
106
-
107
- # required `run` method
108
- def run
109
- # do task stuff here
110
-
111
- access
112
- # access task options from the `options` object
113
- # access all project options from the `project_options` object
114
- end
115
- end
116
- ```
117
-
118
- #### TODO
119
- * optional scripts when creating a template
120
- * write templates
121
- * write tasks
122
-
123
- #### Contributing
124
- 1. Fork it ( http://github.com/brewster1134/new/fork )
125
- 2. Create your feature branch (`git checkout -b my-new-feature`)
126
- 3. Commit your changes (`git commit -am 'Add some feature'`)
127
- 4. Push to the branch (`git push origin my-new-feature`)
128
- 5. Create new Pull Request
data/lib/new/core.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'active_support/core_ext/hash/deep_merge'
2
- require 'active_support/core_ext/hash/keys'
3
- require 'active_support/core_ext/object/deep_dup'
4
- require 'active_support/core_ext/string/inflections'
5
- require 'colorize'
6
- require 'date'
7
- require 'tmpdir'
data/lib/new/dsl.rb DELETED
@@ -1,42 +0,0 @@
1
- module New::Dsl
2
- # Replacement for `puts` that accepts various stylistic arguments
3
- # https://github.com/fazibear/colorize/blob/master/lib/colorize.rb
4
- #
5
- # justify: => [center|ljust|rjust] The type of justification to use
6
- # padding: => [integer] The maximum string size to justify text in
7
- # color: => [integer] See link above for supported colors
8
- # bgcolor: => [integer] See link above for supported colors
9
- # type: => [symbol] Preset colors for [:fail, :success, :warn]
10
- #
11
- def say text = '', args = {}
12
- # Justify options
13
- if args[:justify] && args[:padding]
14
- text = text.send args[:justify], args[:padding]
15
- end
16
-
17
- # Color text
18
- text = text.colorize(color: args[:color]) if args[:color]
19
-
20
- # Color background
21
- text = text.colorize(background: args[:bgcolor]) if args[:bgcolor]
22
-
23
- # Type options
24
- # process last due to the addition of special color codes
25
- text = case args[:type]
26
- when :fail
27
- text.red
28
- when :success
29
- text.green
30
- when :warn
31
- text.yellow
32
- else
33
- text
34
- end
35
-
36
- if args[:indent]
37
- text = (' ' * args[:indent]) + text
38
- end
39
-
40
- puts text
41
- end
42
- end
@@ -1,106 +0,0 @@
1
- require 'erb'
2
- require 'recursive-open-struct'
3
-
4
- module New::Interpolate
5
- # regex to match capital underscored template options names ie [PROJECT_NAME]
6
- FILENAME_RENAME_MATCH = /\[([A-Z_.]+)\]/
7
-
8
- # Convienance method for processing everything
9
- #
10
- def interpolate src_path, options
11
- @src_path = src_path
12
- @options = options
13
-
14
- copy_to_tmp
15
- process_paths
16
- process_files
17
- end
18
-
19
- def dir
20
- File.file?(@src_path) ? @dest_path : File.join(@dest_path, File.basename(@src_path))
21
- end
22
-
23
- # Convert options to OpenStruct so we can use dot notation in the templates
24
- #
25
- def dot_options
26
- @dot_options ||= RecursiveOpenStruct.new(@options)
27
- end
28
-
29
- def to_filename filename
30
- filename.downcase
31
- .gsub(/[^\w\s_-]+/, '')
32
- .gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
33
- .gsub(/\s+/, '_')
34
- end
35
-
36
- private
37
-
38
- # Allow templates to call option values directly
39
- #
40
- def method_missing method
41
- dot_options.send(method.to_sym) || super
42
- end
43
-
44
- def copy_to_tmp
45
- # Create a unique temporary path to store the processed files
46
- @dest_path = Dir.mktmpdir
47
-
48
- # Copy to tmp
49
- FileUtils.cp_r @src_path, @dest_path
50
- end
51
-
52
- # Collect files with a matching value to interpolate
53
- #
54
- def process_paths
55
- get_path = -> type do
56
- Dir.glob(File.join(@dest_path, '**/*')).select do |e|
57
- File.send("#{type}?".to_sym, e) && e =~ FILENAME_RENAME_MATCH
58
- end
59
- end
60
-
61
- # rename directories first
62
- get_path[:directory].each{ |dir| process_path dir }
63
- get_path[:file].each{ |file| process_path file }
64
- end
65
-
66
- # Interpolate filenames with template options
67
- #
68
- def process_path path
69
- new_path = path.gsub FILENAME_RENAME_MATCH do
70
- # Extract interpolated values into symbols
71
- methods = $1.downcase.split('.').map(&:to_sym)
72
-
73
- # Call each method on options
74
- methods.inject(dot_options){ |options, method| options.send(method.to_sym) }
75
- end
76
-
77
- if File.file? path
78
- File.rename path, new_path
79
- else
80
- FileUtils.mv path, new_path
81
- end
82
- end
83
-
84
- # Collect files with an .erb extension to interpolate
85
- #
86
- def process_files
87
- Dir.glob(File.join(@dest_path, '**/*.erb'), File::FNM_DOTMATCH).each do |file|
88
- process_file file
89
- end
90
- end
91
-
92
- # Interpolate erb template data
93
- #
94
- def process_file file
95
- # Process the erb file
96
- processed_file = ERB.new(File.read(file)).result(binding)
97
-
98
- # Overwrite the original file with the processed file
99
- File.open file, 'w' do |f|
100
- f.write processed_file
101
- end
102
-
103
- # Remove the .erb from the file name
104
- File.rename file, file.chomp('.erb')
105
- end
106
- end