file_templater 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: accf9f58ab6f84930e53742a1c5bb5f07cd96b6b
4
- data.tar.gz: 06b7c96c3d4379b98a4bfc27c4b0b83ae9b5bb50
3
+ metadata.gz: 2cbcda6006b6b3e49308db64982a9a48696d10e3
4
+ data.tar.gz: 97595b1474ce2db099e98ae523b7452d402b695a
5
5
  SHA512:
6
- metadata.gz: 08bf8f2095240e726dfad6a33ccb6d3232fbd1050b230453ec670f48bd6814b8718a960543836b4181e509b10d4954ef761bccb769d6c512d2cf65cd4983ce7f
7
- data.tar.gz: 2730f4c54516521f891b75e845d939bd16f405543f18fba51f17094fa9035424e33214a02cc5d93e1011c123f253b574f12c12da013c4329596bb6833abc7c96
6
+ metadata.gz: c9e7450d71bdbf09dbe8479b6d0d06486de3698f12a53a51b74863e57a922e1adc89169b78d876d5cee3a01ecb5a2df40bb6a7ada79d4b264896ba3cba6be629
7
+ data.tar.gz: 51f8a7e76f0f57b45819bff36a04edd0f84a20aea037d814151bc2c5ebc00563bce13baaff7e5388740a2eff4aa13a73a8fffdf07f17c82a9a56ae9ffe4f9cc6
@@ -2,6 +2,9 @@ module FileTemplater
2
2
  class OptionsHandler
3
3
  def initialize(argv)
4
4
  @nomodify = false
5
+
6
+ # Commands that can only be run once.
7
+ @template = nil
5
8
  @binding = nil
6
9
 
7
10
  @actions = []
@@ -15,12 +18,17 @@ module FileTemplater
15
18
  o.on("-t", "--template TEMPLATE",
16
19
  "Load TEMPLATE to insert",
17
20
  "into the current directory") do |t|
18
- @actions << [:template, t]
21
+ can_only_be_used_once @template, "-t"
22
+
23
+ @actions << [:template]
24
+ @template = t
19
25
  end
20
26
 
21
27
  o.on("-b", "--binding BINDING",
22
28
  "Load BINDING as the binding",
23
29
  "for the loaded template") do |b|
30
+ can_only_be_used_once @binding, "-b"
31
+
24
32
  @binding = b
25
33
  end
26
34
 
@@ -47,8 +55,8 @@ module FileTemplater
47
55
  @nomodify = true
48
56
  end
49
57
 
50
- o.on("-c", "--copy TEMPLATE", Array,
51
- "Copies TEMPLATE and corresponding binding",
58
+ o.on("-c", "--copy THING", Array,
59
+ "Copies THING, a template or binding,",
52
60
  "into current directory") do |tb|
53
61
  @actions << [:copy, tb]
54
62
  end
@@ -58,11 +66,16 @@ module FileTemplater
58
66
 
59
67
  o.on_tail("-v", "--version", "Display the version") do
60
68
  puts "File Templater (template) version " + VERSION
69
+ puts
70
+ puts "Copyright (C) 2015 Sam Craig"
71
+ puts "Licensed under the GNU General Public License version 3."
72
+
61
73
  exit
62
74
  end
63
75
 
64
76
  o.on_tail("-h", "--help", "Show this message") do
65
77
  puts o
78
+
66
79
  exit
67
80
  end
68
81
  end
@@ -72,6 +85,9 @@ module FileTemplater
72
85
  end
73
86
 
74
87
  def process_actions
88
+ # All actions should be unique.
89
+ @actions.uniq!
90
+
75
91
  @actions.each do |a|
76
92
  command = a.first
77
93
  arguments = a[1]
@@ -80,7 +96,7 @@ module FileTemplater
80
96
  when :template
81
97
  # arguments is the template name,
82
98
  # @arguments are the extraneous arguments
83
- template = Template.new(arguments, @arguments, nomodify: @nomodify, bind: @binding)
99
+ template = Template.new(@template, @arguments, nomodify: @nomodify, bind: @binding)
84
100
  template.load
85
101
  when :add
86
102
  arguments.each do |ar|
@@ -99,5 +115,13 @@ module FileTemplater
99
115
  end
100
116
  end
101
117
  end
118
+
119
+ def can_only_be_used_once(variable, switch)
120
+ if variable
121
+ puts "The #{switch} switch can only be used once!"
122
+
123
+ exit
124
+ end
125
+ end
102
126
  end
103
127
  end
@@ -1,5 +1,5 @@
1
1
  module FileTemplater
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
 
4
4
  # The hub is where we store our templates and bindings.
5
5
  HUBS = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_templater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Craig