cog 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.
data/bin/cog ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
+ # have this method, so we add it so we get resolved symlinks
4
+ # and compatibility
5
+ unless File.respond_to? :realpath
6
+ class File #:nodoc:
7
+ def self.realpath path
8
+ return realpath(File.readlink(path)) if symlink?(path)
9
+ path
10
+ end
11
+ end
12
+ end
13
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
14
+ require 'rubygems'
15
+ require 'gli'
16
+ require 'cog_version'
17
+ require 'cog'
18
+
19
+ include GLI
20
+
21
+ program_desc 'This is a utility to help you write code generators.'
22
+
23
+ version Cog::VERSION
24
+
25
+ desc 'Write extra information'
26
+ switch [:v,:verbose]
27
+
28
+ desc 'Add cog to a project by generating a Cogfile in the current directory'
29
+ command :project do |c|
30
+ c.action do |global_options, options, args|
31
+ puts 'Created Cogfile'
32
+ FileUtils.touch 'Cogfile'
33
+ end
34
+ end
35
+
36
+ desc 'Create a new template'
37
+ arg_name 'NAME'
38
+ command :template do |c|
39
+ c.action do |global_options, options, args|
40
+ # TODO: implement me
41
+ end
42
+ end
43
+
44
+ pre do |global, command, options, args|
45
+ # Pre logic here
46
+ # Return true to proceed; false to abort and not call the
47
+ # chosen command
48
+ # Use skips_pre before a command to skip this block
49
+ # on that command only
50
+ cogfile = Cog.load_cogfile
51
+ if !cogfile && command && command.name != :project
52
+ puts 'No Cogfile could be found'
53
+ false
54
+ elsif cogfile && command && command.name == :project
55
+ puts "A Cogfile already exists at #{cogfile.path.inspect}"
56
+ false
57
+ else
58
+ global[:cogfile] = cogfile
59
+ true
60
+ end
61
+ end
62
+
63
+ post do |global, command, options, args|
64
+ # Post logic here
65
+ # Use skips_post before a command to skip this
66
+ # block on that command only
67
+ end
68
+
69
+ on_error do |exception|
70
+ # Error logic here
71
+ # return false to skip default error handling
72
+ true
73
+ end
74
+
75
+ exit GLI.run(ARGV)
@@ -0,0 +1,3 @@
1
+ = cog
2
+
3
+ This is the API documentation.
@@ -0,0 +1,40 @@
1
+ require 'cog/config'
2
+ require 'cog/has_template'
3
+
4
+ module Cog
5
+
6
+ class CogfileError < StandardError
7
+ def message
8
+ "in Cogfile, " + super
9
+ end
10
+ end
11
+
12
+ # Loads the +Cogfile+.
13
+ #
14
+ # The +Cogfile+ will be looked for in the present working directory. If none
15
+ # is found there the parent directory will be checked, and then the
16
+ # grandparent, and so on.
17
+ #
18
+ # === Returns
19
+ # An instance of Config which has been configured using the +Cogfile+, if
20
+ # one was found, otherwise +nil+.
21
+ def self.load_cogfile
22
+ parts = Dir.pwd.split File::SEPARATOR
23
+ i = parts.length
24
+ while i >= 0 && !File.exists?(File.join(parts.slice(0, i) + ['Cogfile']))
25
+ i -= 1
26
+ end
27
+ path = File.join(parts.slice(0, i) + ['Cogfile']) if i >= 0
28
+ if path
29
+ cogfile = Config.new path
30
+ begin
31
+ b = cogfile.instance_eval {binding}
32
+ eval File.read(path), b
33
+ rescue Exception => e
34
+ raise CogfileError.new(e.to_s)
35
+ end
36
+ cogfile
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,19 @@
1
+ module Cog
2
+
3
+ # When the Cogfile is processed, +self+ will be set to an instance of this
4
+ # object at the global context.
5
+ class Config
6
+ attr_reader :path
7
+
8
+ # Create an empty config object
9
+ #
10
+ # === Arguments
11
+ # * +path+ - The path to the +Cogfile+ which will be used to configure
12
+ # this object.
13
+ def initialize(path)
14
+ @path = path
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,12 @@
1
+ module Cog
2
+
3
+ # Mixin for classes that can use templates to generate code
4
+ module HasTemplate
5
+
6
+ def cog(template_name)
7
+
8
+ end
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ module Cog
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cog
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Kevin Tonon
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-12 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rake
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rdoc
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ description:
49
+ email: kevin@betweenconcepts.com
50
+ executables:
51
+ - cog
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - cog.rdoc
56
+ files:
57
+ - bin/cog
58
+ - lib/cog/config.rb
59
+ - lib/cog/has_template.rb
60
+ - lib/cog.rb
61
+ - lib/cog_version.rb
62
+ - cog.rdoc
63
+ homepage: https://github.com/ktonon/cog
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --title
69
+ - cog
70
+ - --main
71
+ - cog.rdoc
72
+ - -ri
73
+ require_paths:
74
+ - lib
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.15
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: This is a utility to help you write code generators.
101
+ test_files: []
102
+