tschmidt-interface-generator 0.1.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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Terry Schmidt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = interface-generator
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Terry Schmidt. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "interface-generator"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "tschmidt@ext-inc.com"
10
+ gem.homepage = "http://github.com/tschmidt/interface-generator"
11
+ gem.authors = ["Terry Schmidt"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "interface-generator #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{interface-generator}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Terry Schmidt"]
9
+ s.date = %q{2009-08-04}
10
+ s.email = %q{tschmidt@ext-inc.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "interface-generator.gemspec",
23
+ "lib/interface-generator.rb",
24
+ "rails_generators/interface_generator.rb",
25
+ "rails_generators/templates/model.rb",
26
+ "test/interface-generator_test.rb",
27
+ "test/test_helper.rb"
28
+ ]
29
+ s.has_rdoc = true
30
+ s.homepage = %q{http://github.com/tschmidt/interface-generator}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.1}
34
+ s.summary = %q{TODO}
35
+ s.test_files = [
36
+ "test/interface-generator_test.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 2
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ else
46
+ end
47
+ else
48
+ end
49
+ end
@@ -0,0 +1 @@
1
+ # move along, nothing to see here. this is just a gem wrapper for a rails generator.
@@ -0,0 +1,66 @@
1
+ class InterfaceGenerator < Rails::Generator::NamedBase
2
+ attr_accessor :plugin_path, :credential_fields, :template_fields, :datasource_fields
3
+
4
+ # Rails::Generator::Base gives us a lot of default methods that are not well
5
+ # known when you create a new generator. So, to put them at the fore front I
6
+ # have listed them here. When you run
7
+ #
8
+ # script/generate interface SipTrunk phone_call_interface
9
+ #
10
+ # you will get the following methods (the return value is also shown)
11
+ #
12
+ # name: SipTrunk
13
+ # class_name: SipTrunk
14
+ # singular_name: sip_trunk
15
+ # plural_name: sip_trunks
16
+ # table_name: sip_trunks
17
+ # class_path:
18
+ # file_path: sip_trunk
19
+ # class_nesting:
20
+ # class_nesting_depth: 0
21
+ # args: ["phone_call_interface"]
22
+ def initialize(runtime_args, runtime_options = {})
23
+ super
24
+ puts singular_name
25
+ @name.gsub('Interface', '') if name.include?("Interface")
26
+ @name = "#{name}Interface"
27
+ @class_name = "#{class_name}Interface"
28
+ @singular_name = "#{singular_name}_interface"
29
+ @plural_name = "#{singular_name}_interfaces"
30
+ @table_name = @plural_name
31
+
32
+ puts singular_name
33
+
34
+ @plugin_path = "vendor/plugins/#{file_name}"
35
+
36
+ args.each do |arg|
37
+ if arg.include? ':'
38
+ cat, vals = arg.split(':')
39
+ case cat
40
+ when "credential_fields"
41
+ @credential_fields = val_parse!(vals)
42
+ when "template_fields"
43
+ @template_fields = val_parse!(vals)
44
+ when "datasource_fields"
45
+ @datasource_fields = val_parse!(vals)
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ def manifest
52
+ record do |m|
53
+ # Check for class naming collisions.
54
+ m.class_collisions class_name
55
+
56
+ m.directory "#{plugin_path}/app"
57
+ m.directory "#{plugin_path}/app/models"
58
+
59
+ m.template "model.rb", "#{plugin_path}/app/models/#{file_name}.rb"
60
+ end
61
+ end
62
+
63
+ def val_parse!(vals)
64
+ vals.split.map {|val| ":#{val}"}.join(', ')
65
+ end
66
+ end
@@ -0,0 +1,13 @@
1
+ class <%= name %> < Interface
2
+
3
+ <%- if credential_fields -%>
4
+ credential_fields <%= credential_fields %>
5
+ <%- end -%>
6
+ <%- if datasource_fields -%>
7
+ datasource_fields <%= datasource_fields %>
8
+ <%- end -%>
9
+ <%- if template_fields -%>
10
+ template_fields <%= template_fields %>
11
+ <%- end -%>
12
+
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class InterfaceGeneratorTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'interface-generator'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tschmidt-interface-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Terry Schmidt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-04 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: tschmidt@ext-inc.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - interface-generator.gemspec
33
+ - lib/interface-generator.rb
34
+ - rails_generators/interface_generator.rb
35
+ - rails_generators/templates/model.rb
36
+ - test/interface-generator_test.rb
37
+ - test/test_helper.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/tschmidt/interface-generator
40
+ licenses:
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.5
62
+ signing_key:
63
+ specification_version: 2
64
+ summary: TODO
65
+ test_files:
66
+ - test/interface-generator_test.rb
67
+ - test/test_helper.rb