infraruby-init 3.7.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbacaa54d6d745f102d71499bcf54ae8b34485d4
4
+ data.tar.gz: df8ba06930a623bbd0212f1c68cef29d391366fa
5
+ SHA512:
6
+ metadata.gz: 8adfa790fc4deed9828f4f1b9d4657ffcc0011ac886a8d10c6444e25daacb974c85591faa56b441c04e2b97562a42e51fcf308ba833f7d8dcbae4fe56f248dbe
7
+ data.tar.gz: 0dceb826e470daca27cf02b94ef7704d45542957a6812c82498ed523d07021125c9fedb706f964a5bbb696d8bd915443231fb61720c8a79f349fc434dd1546e5
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011-2015 InfraRuby Vision
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
+ DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ InfraRuby init
2
+ ==============
3
+
4
+ This gem provides the InfraRuby init.
5
+
6
+
7
+ Example
8
+ -------
9
+
10
+ infraruby-init hello
11
+ cd hello
12
+ bundle install
13
+ rake --tasks
14
+
15
+
16
+ Support
17
+ -------
18
+
19
+ InfraRuby Vision
20
+ rubygems@infraruby.com
21
+
22
+ http://infraruby.com/
23
+ https://github.com/InfraRuby
24
+ https://twitter.com/InfraRuby
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "infraruby-init"
4
+
5
+ def usage
6
+ STDERR.puts "Usage: infraruby-init name"
7
+ STDERR.puts "Example:"
8
+ STDERR.puts "\t" + "infraruby-init hello"
9
+ abort
10
+ end
11
+
12
+ if ARGV.size != 1
13
+ usage
14
+ end
15
+
16
+ name = ARGV.shift
17
+
18
+ unless InfraRuby.valid_name?(name)
19
+ abort "invalid name: #{name}"
20
+ end
21
+
22
+ if File.exist?(name)
23
+ abort "directory exists: #{name}"
24
+ end
25
+
26
+ unit = InfraRuby.unit_for_name(name)
27
+
28
+ InfraRuby.init(name, unit)
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = "ruby"
3
+ s.name = "infraruby-init"
4
+ s.version = "3.7.0"
5
+ s.licenses = ["MIT"]
6
+ s.author = "InfraRuby Vision"
7
+ s.email = "rubygems@infraruby.com"
8
+ s.homepage = "http://infraruby.com/"
9
+ s.summary = "InfraRuby init"
10
+ s.description = "InfraRuby init"
11
+ s.executables = ["infraruby-init"]
12
+ s.files = Dir["**/*"]
13
+ s.add_runtime_dependency "infraruby-base", "~> 3.7"
14
+ s.add_runtime_dependency "fab", "~> 0.2"
15
+ s.add_development_dependency "infraruby-task", "~> 3.7"
16
+ s.add_development_dependency "rspec", "~> 3.0"
17
+ end
@@ -0,0 +1,5 @@
1
+ require "infraruby-base"
2
+
3
+ require "fab"
4
+
5
+ InfraRuby.load_parent_library(__dir__)
data/ruby/InfraRuby.rb ADDED
@@ -0,0 +1,43 @@
1
+ module InfraRuby
2
+ VALID_NAME_REGEXP = /\A[a-z][0-9a-z]*(_[a-z][0-9a-z]*)*(-[a-z][0-9a-z]*(_[a-z][0-9a-z]*)*)*\z/
3
+
4
+ class << self
5
+ def valid_name?(name)
6
+ return name =~ VALID_NAME_REGEXP
7
+ end
8
+
9
+ def unit_for_name(name)
10
+ return name.split("-").first.split("_").map(&:capitalize).join
11
+ end
12
+
13
+ def init(name, unit)
14
+ d = Directory.new(name, unit)
15
+ d.instance_eval do
16
+ mkdir(name) do
17
+ write_readme
18
+ write_gemfile
19
+ write_gemspec
20
+ write_rakefile
21
+ mkdir("bin") do
22
+ write_main
23
+ end
24
+ mkdir("lib") do
25
+ write_feature
26
+ end
27
+ mkdir("ruby") do
28
+ write_module
29
+ mkdir(unit)
30
+ end
31
+ mkdir("spec") do
32
+ write_spec_helper
33
+ mkdir("ruby") do
34
+ write_example_group
35
+ end
36
+ end
37
+ mkdir("pool")
38
+ end
39
+ end
40
+ return
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,111 @@
1
+ module InfraRuby
2
+ class Directory < Fab::Directory
3
+ def initialize(name, unit)
4
+ @name = name
5
+ @unit = unit
6
+ return
7
+ end
8
+
9
+ def write_readme
10
+ write("README.md", <<-END)
11
+ END
12
+ end
13
+
14
+ def write_gemfile
15
+ write("Gemfile", <<-END)
16
+ source "https://rubygems.org/"
17
+ gemspec
18
+ END
19
+ end
20
+
21
+ def write_gemspec
22
+ write("#{@name}.gemspec", <<-END)
23
+ Gem::Specification.new do |s|
24
+ s.name = "#{@name}"
25
+ s.version = "0.0.0"
26
+ s.author = "FIXME"
27
+ s.summary = "FIXME"
28
+ s.executables = ["#{@name}-main"]
29
+ s.files = Dir["**/*"]
30
+ s.add_runtime_dependency "infraruby-base", "~> 3.7"
31
+ s.add_development_dependency "infraruby-task", "~> 3.7"
32
+ s.add_development_dependency "rspec", "~> 3.0"
33
+ end
34
+ END
35
+ end
36
+
37
+ def write_rakefile
38
+ write("Rakefile", <<-END)
39
+ require "infraruby-task"
40
+
41
+ USE_INFRARUBY_CORE = false
42
+
43
+ loader = InfraRuby.task_loader
44
+ loader.add_program("#{@name}-main")
45
+ loader.load_tasks
46
+
47
+ if USE_INFRARUBY_CORE
48
+ task "main" => "program:#{@name}-main:core:execute"
49
+ task "spec" => "spec:core:execute"
50
+ else
51
+ task "main" => "program:#{@name}-main:interpret:ruby"
52
+ task "spec" => "spec:interpret:ruby"
53
+ end
54
+
55
+ task "default" => "spec"
56
+ END
57
+ end
58
+
59
+ def write_main
60
+ write("#{@name}-main", <<-END)
61
+ #!/usr/bin/env ruby
62
+
63
+ require "#{@name}"
64
+
65
+ puts #{@unit}.message
66
+ END
67
+ end
68
+
69
+ def write_feature
70
+ write("#{@name}.rb", <<-END)
71
+ require "infraruby-base"
72
+
73
+ InfraRuby.load_parent_library(__dir__)
74
+ END
75
+ end
76
+
77
+ def write_module
78
+ write("#{@unit}.rb", <<-END)
79
+ ## <>
80
+ module #{@unit}
81
+ ## -> String
82
+ def self.message
83
+ return "#{@name}"
84
+ end
85
+ end
86
+ END
87
+ end
88
+
89
+ def write_spec_helper
90
+ write("spec_helper.rb", <<-END)
91
+ require "#{@name}"
92
+
93
+ RSpec.configure do |config|
94
+ # ...
95
+ end
96
+ END
97
+ end
98
+
99
+ def write_example_group
100
+ write("#{@unit}_spec.rb", <<-END)
101
+ require "spec_helper"
102
+
103
+ RSpec.describe "#{@unit}.message" do
104
+ it "should return message" do
105
+ expect(#{@unit}.message).to eq("#{@name}")
106
+ end
107
+ end
108
+ END
109
+ end
110
+ end
111
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: infraruby-init
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.7.0
5
+ platform: ruby
6
+ authors:
7
+ - InfraRuby Vision
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: infraruby-base
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fab
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: infraruby-task
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: InfraRuby init
70
+ email: rubygems@infraruby.com
71
+ executables:
72
+ - infraruby-init
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - MIT-LICENSE
77
+ - README.md
78
+ - bin/infraruby-init
79
+ - infraruby-init.gemspec
80
+ - lib/infraruby-init.rb
81
+ - ruby/InfraRuby.rb
82
+ - ruby/InfraRuby/Directory.rb
83
+ homepage: http://infraruby.com/
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: InfraRuby init
107
+ test_files: []