ki_middleman 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/ki_middleman +44 -39
  2. data/lib/ki_middleman/version.rb +1 -1
  3. metadata +15 -15
data/bin/ki_middleman CHANGED
@@ -3,48 +3,53 @@ require 'methadone'
3
3
  require 'ki_middleman'
4
4
  require 'fileutils'
5
5
 
6
- include Methadone::Main
7
- include Methadone::CLILogging
6
+ module KiMiddleman
7
+ module CLI
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
8
10
 
9
- def init
10
- config_dir = Kiseru::ConfigDir.new
11
- assets_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets'))
12
- assets_file = File.join(assets_dir, 'default_transforms.rb')
13
- # TODO - duplicated file name here!
14
- new_file = config_dir.file('transforms.rb')
15
- if File.exists?(new_file)
16
- $stdout.puts "Cannot write #{new_file}. File already exists."
17
- else
18
- $stdout.puts "Copying default transform file to #{new_file}"
19
- FileUtils.cp(assets_file, new_file)
20
- end
21
- end
11
+ def init
12
+ config_dir = Kiseru::ConfigDir.new
13
+ assets_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets'))
14
+ assets_file = File.join(assets_dir, 'default_transforms.rb')
15
+ # TODO - duplicated file name here!
16
+ new_file = config_dir.file('transforms.rb')
17
+ if File.exists?(new_file)
18
+ $stdout.puts "Cannot write #{new_file}. File already exists."
19
+ else
20
+ $stdout.puts "Copying default transform file to #{new_file}"
21
+ FileUtils.cp(assets_file, new_file)
22
+ end
23
+ end
22
24
 
23
- main do |arg|
24
- if options[:init]
25
- init
26
- elsif options[:to]
27
- begin
28
- pretty = $stdout.tty?
25
+ main do |arg|
26
+ if options[:init]
27
+ init
28
+ elsif options[:to]
29
+ begin
30
+ pretty = $stdout.tty?
29
31
 
30
- output_type = options[:to]
31
- config = KiMiddleman::Config.from_file(Kiseru::ConfigDir.new.file('transforms.rb'))
32
- input = MultiJson.load($stdin.read)
33
- output = config.convert_data_to_format(input, output_type)
34
- $stdout.write MultiJson.dump(output, :pretty => pretty)
35
- rescue MultiJson::DecodeError => e
36
- $stderr.puts "Invalid JSON"
37
- exit 1
38
- rescue KiMiddleman::ConfigError => e
39
- $stderr.puts e.message
40
- exit 1
32
+ output_type = options[:to]
33
+ config = KiMiddleman::Config.from_file(Kiseru::ConfigDir.new.file('transforms.rb'))
34
+ input = MultiJson.load($stdin.read)
35
+ output = config.convert_data_to_format(input, output_type)
36
+ $stdout.write MultiJson.dump(output, :pretty => pretty)
37
+ rescue MultiJson::DecodeError => e
38
+ $stderr.puts "Invalid JSON"
39
+ exit 1
40
+ rescue KiMiddleman::ConfigError => e
41
+ $stderr.puts e.message
42
+ exit 1
43
+ end
44
+ end
41
45
  end
42
- end
43
- end
44
46
 
45
- version KiMiddleman::VERSION
46
- description 'Transforms JSON into other JSON'
47
+ version KiMiddleman::VERSION
48
+ description 'Transforms JSON into other JSON'
49
+
50
+ on("--to FORMAT", "The output JSON format")
51
+ on("--init", "Set up the default config files")
52
+ go!
47
53
 
48
- on("--to FORMAT", "The output JSON format")
49
- on("--init", "Set up the default config files")
50
- go!
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module KiMiddleman
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ki_middleman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-08-15 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
17
- requirement: &70310574886120 !ruby/object:Gem::Requirement
17
+ requirement: &70130545466640 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70310574886120
25
+ version_requirements: *70130545466640
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: methadone
28
- requirement: &70310574885700 !ruby/object:Gem::Requirement
28
+ requirement: &70130545466220 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70310574885700
36
+ version_requirements: *70130545466220
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: map
39
- requirement: &70310574885280 !ruby/object:Gem::Requirement
39
+ requirement: &70130545465800 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70310574885280
47
+ version_requirements: *70130545465800
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: debugger
50
- requirement: &70310574884860 !ruby/object:Gem::Requirement
50
+ requirement: &70130545465380 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70310574884860
58
+ version_requirements: *70130545465380
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &70310586012480 !ruby/object:Gem::Requirement
61
+ requirement: &70130545464960 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70310586012480
69
+ version_requirements: *70130545464960
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simplecov
72
- requirement: &70310586012060 !ruby/object:Gem::Requirement
72
+ requirement: &70130545464540 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70310586012060
80
+ version_requirements: *70130545464540
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec
83
- requirement: &70310586011640 !ruby/object:Gem::Requirement
83
+ requirement: &70130545464120 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70310586011640
91
+ version_requirements: *70130545464120
92
92
  description: Transforms JSON into other JSON
93
93
  email:
94
94
  - ben@freeagent.com