working 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/bin/working-init CHANGED
@@ -1,47 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- def green_say verb, noun
4
- puts " \e[32;1m#{verb}\e[0m #{noun}"
5
- end
6
-
7
- def is_rails?; File.exists? 'config/environment.ru' end
8
-
9
- fail "No automatic setup for Rails, yet" if is_rails?
10
-
11
- unless Dir.exists? 'test'
12
- green_say 'mkdir', 'test'
13
- Dir.mkdir 'test'
14
- end
15
-
16
- {
17
- 'Gemfile' => [
18
- 'source :rubygems',
19
- %{group :development do gem 'working' end},
20
- # Rails TODO %{group :development do gem 'pry-rails' end},
21
- ],
22
- 'Guardfile' => [
23
- %{require 'working/guard'},
24
- '# vim ft=ruby',
25
- ],
26
- 'Rakefile' => [
27
- %{require 'working/rake_tasks'}
28
- ],
29
- 'test/test_helper.rb' => [
30
- %{require 'working/test_helper'},
31
- # Rails TODO %{require 'working/rails_test_helper'},
32
- %{# Spork.prefork doesn't like when this is missing},
33
- ],
34
- }.each do |path, content|
35
- if File.exist? path
36
- green_say 'found', path
37
- else
38
- green_say 'create', path
39
- File.write path, ''
40
- end
41
- existing = File.read path
42
- content.each do |line|
43
- next if existing[line]
44
- puts " #{line}"
45
- File.write path, line + "\n", mode: 'a'
46
- end
47
- end
2
+ require 'working/init'
3
+ Working.cli_plain ARGV
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+ module Working
3
+ def self.cli_plain argv
4
+ fail RAILS_TODO_APOLOGY if is_rails?
5
+ Working::PlainInitializer.new.run argv
6
+ end
7
+
8
+ def self.is_rails?; File.exists? 'config/environment.ru' end
9
+
10
+ class Initializer
11
+ RAILS_TODO_APOLOGY = <<-EOT
12
+ No automatic setup for Rails, yet. ☹
13
+ Try mimicking https://github.com/rking/monkeynote
14
+ # Basically, it'll be:
15
+ # test/test_helper.rb
16
+ # %{require 'working/rails_test_helper'},
17
+ # %{# Spork.prefork doesn't like when this is missing},
18
+ # Gemfile
19
+ # %{group :development do\n gem 'pry-rails'\nend},
20
+ # Guardfile
21
+ # require 'working/guard-rails'
22
+ EOT
23
+
24
+ def run argv
25
+ unless Dir.exists? 'test'
26
+ heading 'mkdir', 'test'
27
+ Dir.mkdir 'test'
28
+ end
29
+ @contents.each do |path, content|
30
+ if File.exist? path
31
+ heading 'found', path
32
+ else
33
+ heading 'create', path
34
+ File.write path, ''
35
+ end
36
+ existing = File.read path
37
+ content.each do |line|
38
+ next if existing[line]
39
+ puts line
40
+ File.write path, line + "\n", mode: 'a'
41
+ end
42
+ end
43
+ end
44
+
45
+ def initialize contents
46
+ (@contents ||= {}).merge! contents
47
+ end
48
+
49
+ def heading verb, noun
50
+ puts "\e[32m #{verb}\e[0;1m: \e[36;1m#{noun}\e[0m ".center 60, ?—
51
+ end
52
+
53
+ end
54
+
55
+ require 'date'
56
+ class PlainInitializer < Initializer
57
+ def initialize
58
+ super(
59
+ 'Gemfile' => [
60
+ 'source :rubygems',
61
+ %{group :development do\n gem 'working'\nend},
62
+ ],
63
+ 'Guardfile' => [
64
+ %{require 'working/guard'},
65
+ ],
66
+ 'Rakefile' => [
67
+ %{require 'working/rake_tasks'}
68
+ ],
69
+ 'test/test_helper.rb' => [
70
+ %{# Run this via 'beg'},
71
+ %{require 'working/test_helper'},
72
+ %{Spork.each_run do\n Dir['lib/**/*.rb'].each{|e| load e}\nend},
73
+ %{# Spork.prefork doesn't like when this is missing},
74
+ ],
75
+ 'LICENSE.txt' => [
76
+ "Copyleft (ↄ) #{Date.today.year} #{ENV['GIT_AUTHOR_NAME']} — CC0/Public Domain."
77
+ ]
78
+ )
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,3 @@
1
1
  module Working
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: working
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry-de
@@ -136,12 +136,13 @@ files:
136
136
  - Gemfile
137
137
  - Guardfile
138
138
  - LICENSE.txt
139
- - README.md
139
+ - README.rdoc
140
140
  - Rakefile
141
141
  - bin/working-init
142
142
  - lib/working.rb
143
143
  - lib/working/gemspec.rb
144
144
  - lib/working/guard.rb
145
+ - lib/working/init.rb
145
146
  - lib/working/rake_tasks.rb
146
147
  - lib/working/test_helper.rb
147
148
  - lib/working/version.rb