service_contract-generator 0.0.1

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: aac254fa739ca42d88359f79b44b92bf3d559bbc
4
+ data.tar.gz: 39682e2aaed1f30826270b2e62f8f3516026f44c
5
+ SHA512:
6
+ metadata.gz: d2a55257ef07c152234f3a0903b8df8e9068dc8d9388c008f03ea0351708836c57af18166979e835d96a0b00d10e246767300756b9da03230e09dc6a1a10e45a
7
+ data.tar.gz: 9695cc60f495f88ca4523bcfec491e09d0ba7522335d2c79ee37e97597b2230791b6d5a8bb5af01fb5887a3f4aa518cfca795732c1ae15c827c5592a70cda865
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in service_contract-generator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jeff Ching
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 ADDED
@@ -0,0 +1,31 @@
1
+ # ServiceContract::Generator
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'service_contract-generator'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install service_contract-generator
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/service_contract-generator/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path("../../lib", __FILE__))
4
+ require 'service_contract-generator'
5
+
6
+ ServiceContract::Generator::CLI.start(ARGV)
@@ -0,0 +1 @@
1
+ require 'service_contract/generator'
@@ -0,0 +1,5 @@
1
+ module ServiceContract
2
+ module Generator
3
+ autoload :CLI, 'service_contract/generator/cli'
4
+ end
5
+ end
@@ -0,0 +1,78 @@
1
+ require 'thor'
2
+ require 'active_support/inflector'
3
+ require 'erb'
4
+
5
+ module ServiceContract
6
+ module Generator
7
+ class CLI < Thor
8
+
9
+ desc "new CONTRACT_NAME", "bootstraps a new service_contract"
10
+ def new(contract_name)
11
+ path = contract_name.gsub("-", "/")
12
+ module_name = ActiveSupport::Inflector.camelize(path)
13
+
14
+ # create directory structure
15
+ commands = [
16
+ # create gem stub
17
+ %{bundle gem #{contract_name}},
18
+
19
+ # create contracts folder
20
+ %{mkdir -p #{contract_name}/contracts/},
21
+ %{touch #{contract_name}/contracts/},
22
+
23
+ # append tasks to Rakefile
24
+ %{echo "require 'service_contract/tasks'" >> #{contract_name}/Rakefile}
25
+ ]
26
+ commands.each do |command|
27
+ puts command
28
+ `#{command}`
29
+ end
30
+
31
+ # add service_contract to .gemspec
32
+ gemspec = "#{contract_name}/#{contract_name}.gemspec"
33
+ dependency_line = `grep -m 1 -n '.add_de' #{gemspec}`
34
+ matched = false
35
+ output = ""
36
+ File.open(gemspec, "r") do |file|
37
+ file.each_line do |line|
38
+ puts line
39
+ if !matched && match = line.match(/([^\.]+)\.add_de/)
40
+ puts "matched"
41
+ output += %{#{match[1]}.add_dependency "service_contract"\n}
42
+ matched = true
43
+ end
44
+ output += line
45
+ end
46
+ end
47
+ puts output
48
+ File.open(gemspec, "w") do |file|
49
+ file.write(output)
50
+ end
51
+ # if match = dependency_line.match(/(\d+):([^\.]+)\.add_de/)
52
+ # line_number = match[1]
53
+ # new_line = %{#{match[2]}.add_dependency "service_contract"}
54
+ # gemspec_contents = ""
55
+
56
+ # puts new_line
57
+ # command = %{sed -i '#{line_number}i\\ #{new_line}' #{gemspec}}
58
+ # puts command
59
+ # # `#{command}`
60
+ # end
61
+
62
+ # template files
63
+ path_to_root = (Array.new(2 + module_name.split("::").length) {".."}).join("/")
64
+ service_name = ActiveSupport::Inflector.humanize(contract_name)
65
+ b = binding()
66
+ Dir.glob(File.expand_path("../../../../template/*.erb", __FILE__)).each do |template|
67
+ erb = ERB.new(File.read(template))
68
+ output_file = File.join(contract_name, 'lib', path, File.basename(template, ".erb"))
69
+ puts "writing template: #{output_file}"
70
+ File.open(output_file, 'w') do |file|
71
+ file.write(erb.result(b))
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ module ServiceContract
2
+ module Generator
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'service_contract/generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "service_contract-generator"
8
+ spec.version = ServiceContract::Generator::VERSION
9
+ spec.authors = ["Jeff Ching"]
10
+ spec.email = ["jching@avvo.com"]
11
+ spec.summary = %q{Generates service contracts}
12
+ spec.description = %q{Binary to help generate service contracts}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor"
22
+ spec.add_dependency "activesupport"
23
+ spec.add_dependency "bundler"
24
+
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,7 @@
1
+ class <%= module_name %>::Documentation < ServiceContract::Avro::Documentation
2
+ helpers do
3
+ def service
4
+ <%= module_name %>::Service
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class <%= module_name %>::Service < ServiceContract::Avro::Service
2
+ class << self
3
+ def data_dir
4
+ File.expand_path("<%= path_to_root %>/contracts", __FILE__)
5
+ end
6
+
7
+ def title
8
+ "<%= service_name %>"
9
+ end
10
+
11
+ def description
12
+ "<%= service_name %>"
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: service_contract-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Ching
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Binary to help generate service contracts
70
+ email:
71
+ - jching@avvo.com
72
+ executables:
73
+ - service_contract
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/service_contract
83
+ - lib/service_contract-generator.rb
84
+ - lib/service_contract/generator.rb
85
+ - lib/service_contract/generator/cli.rb
86
+ - lib/service_contract/generator/version.rb
87
+ - service_contract-generator.gemspec
88
+ - template/documentation.rb.erb
89
+ - template/service.rb.erb
90
+ homepage: ''
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Generates service contracts
114
+ test_files: []
115
+ has_rdoc: