adhearsion-loquacious 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+
2
+ require File.expand_path('../lib/loquacious', File.dirname(__FILE__))
3
+
4
+ RSpec.configure do |config|
5
+ # Use color in STDOUT
6
+ config.color_enabled = true
7
+
8
+ # Use color not only in STDOUT but also in pagers and files
9
+ config.tty = true
10
+
11
+ # Use the specified formatter
12
+ config.formatter = :documentation # :progress, :html, :textmate
13
+
14
+ # == Mock Framework
15
+ #
16
+ # RSpec uses it's own mocking framework by default. If you prefer to
17
+ # use mocha, flexmock or RR, uncomment the appropriate line:
18
+ #
19
+ # config.mock_with :mocha
20
+ # config.mock_with :flexmock
21
+ # config.mock_with :rr
22
+
23
+ Loquacious::Undefined.io = StringIO.new
24
+
25
+ config.before :each do
26
+ Loquacious::Undefined.io.clear
27
+
28
+ table = Loquacious::Configuration.instance_variable_get(:@table)
29
+ table.clear
30
+
31
+ Loquacious.configuration_for('specs') do
32
+ first 'foo', :desc => 'foo method'
33
+ second 'bar', :desc => 'bar method'
34
+
35
+ desc 'the third group'
36
+ third {
37
+ answer 42, :desc => 'life the universe and everything'
38
+ question :symbol, :desc => 'perhaps you do not understand'
39
+ }
40
+ end
41
+ end
42
+ end
43
+
44
+ class StringIO
45
+ alias :_readline :readline
46
+ def readline
47
+ @pos ||= 0
48
+ seek @pos
49
+ line = _readline
50
+ @pos = tell
51
+ return line
52
+ rescue EOFError
53
+ nil
54
+ end
55
+
56
+ def clear
57
+ @pos = 0
58
+ seek 0
59
+ truncate 0
60
+ end
61
+
62
+ def to_s
63
+ @pos = tell
64
+ seek 0
65
+ str = read
66
+ seek @pos
67
+ return str
68
+ end
69
+ end
70
+
@@ -0,0 +1,53 @@
1
+
2
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
+
4
+ describe String do
5
+
6
+ it "reduces to a size by replacing characters from the middle" do
7
+ "this is a longish string".reduce(10).should be == "this...ing"
8
+ "this is a longish string".reduce(15).should be == "this i...string"
9
+ "this is a longish string".reduce(24).should be == "this is a longish string"
10
+
11
+ "this is a longish string".reduce(10, '--').should be == "this--ring"
12
+ end
13
+
14
+ it "indents by a given number of spaces" do
15
+ "hello".indent(2).should be == " hello"
16
+ "hello\nworld".indent(4).should be == " hello\n world"
17
+ " a\nslightly\n longer\n string\n".indent(2).should be == " a\n slightly\n longer\n string\n "
18
+ end
19
+
20
+ it "indents using a leader string" do
21
+ "hello".indent("foo ").should be == "foo hello"
22
+ "hello\nworld".indent("...").should be == "...hello\n...world"
23
+ " a\nslightly\n longer\n string\n".indent("#").should be == "# a\n#slightly\n# longer\n# string\n#"
24
+ end
25
+
26
+ it "removes a leading gutter from all lines" do
27
+ str = " | foo"
28
+ result = str.gutter!
29
+ result.should be == " foo"
30
+ result.should equal(str)
31
+
32
+ str = <<-STRING
33
+ | And this is where gutters really shine!
34
+ | HERE DOCS!!
35
+ ||they are the best
36
+ |
37
+ | You can indent stuff nicely and all that
38
+ |all done now
39
+ STRING
40
+
41
+ str.gutter!
42
+ str.should be == " And this is where gutters really shine!\n HERE DOCS!!\n|they are the best\n\n You can indent stuff nicely and all that\nall done now\n"
43
+ end
44
+
45
+ it "creates a copy when removing a leading gutter" do
46
+ str = " | foo"
47
+ result = str.gutter
48
+ result.should be == " foo"
49
+ result.should_not equal(str)
50
+ end
51
+ end
52
+
53
+ # EOF
@@ -0,0 +1,28 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ describe Loquacious::Utility do
4
+ let(:obj) {
5
+ Loquacious.configuration_for('app') {
6
+ name :testing, :desc => "Defines the name", :transform => Proc.new{|arg| arg.to_sym }
7
+ foo 'bar', :desc => "FooBar"
8
+ id 42, :desc => "Ara T. Howard"
9
+ desc "bar"
10
+ bar {
11
+ recur 'sive'
12
+ baz {
13
+ inner 'config'
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ describe "#env_var_name" do
20
+ it "returns the correct name for a config value and its object" do
21
+ ::Loquacious::Utility.env_var_name("inner", obj.bar.baz).should == "LOQ_APP_BAR_BAZ_INNER"
22
+ end
23
+
24
+ it "only takes the last part after a dot for a key name" do
25
+ ::Loquacious::Utility.env_var_name("barbaz.inner", obj.bar.baz).should == "LOQ_APP_BAR_BAZ_INNER"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ 1.9.2
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adhearsion-loquacious
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Pease
9
+ - Adhearsion Team
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-01-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: &2164540760 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '2.6'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *2164540760
26
+ description: ! "Descriptive configuration files for Ruby written in Ruby.\n\nLoquacious
27
+ provides a very open configuration system written in ruby and\ndescriptions for
28
+ each configuration attribute. The attributes and descriptions\ncan be iterated over
29
+ allowing for helpful information about those attributes to\nbe displayed to the
30
+ user.\n\nIn the simple case we have a file something like\n\n Loquacious.configuration_for('app')
31
+ {\n name 'value', :desc => \"Defines the name\"\n foo 'bar', :desc => \"FooBar\"\n
32
+ \ id 42, :desc => \"Ara T. Howard\"\n }\n\nWhich can be loaded via the
33
+ standard Ruby loading mechanisms\n\n Kernel.load 'config/app.rb'\n\nThe attributes
34
+ and their descriptions can be printed by using a Help object\n\n help = Loquacious.help_for('app')\n
35
+ \ help.show :values => true # show the values for the attributes, too\n\nDescriptions
36
+ are optional, and configurations can be nested arbitrarily deep.\n\n Loquacious.configuration_for('nested')
37
+ {\n desc \"The outermost level\"\n a {\n desc \"One more level in\"\n
38
+ \ b {\n desc \"Finally, a real value\"\n c 'value'\n }\n
39
+ \ }\n }\n\n config = Loquacious.configuration_for('nested')\n\n p config.a.b.c
40
+ \ #=> \"value\"\n\nAnd as you can see, descriptions can either be given inline after
41
+ the value or\nthey can appear above the attribute and value on their own line."
42
+ email:
43
+ - tim.pease@gmail.com
44
+ - all@adhearsion.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files:
48
+ - History.txt
49
+ - README.rdoc
50
+ files:
51
+ - .gitignore
52
+ - Guardfile
53
+ - History.txt
54
+ - README.rdoc
55
+ - Rakefile
56
+ - adhearsion-loquacious.gemspec
57
+ - examples/gutters.rb
58
+ - examples/nested.rb
59
+ - examples/simple.rb
60
+ - lib/loquacious.rb
61
+ - lib/loquacious/configuration.rb
62
+ - lib/loquacious/configuration/help.rb
63
+ - lib/loquacious/configuration/iterator.rb
64
+ - lib/loquacious/core_ext/string.rb
65
+ - lib/loquacious/undefined.rb
66
+ - lib/loquacious/utility.rb
67
+ - loquacious.gemspec
68
+ - spec/configuration_spec.rb
69
+ - spec/help_spec.rb
70
+ - spec/iterator_spec.rb
71
+ - spec/loquacious_spec.rb
72
+ - spec/spec_helper.rb
73
+ - spec/string_spec.rb
74
+ - spec/utility_spec.rb
75
+ - version.txt
76
+ homepage: http://rubygems.org/gems/adhearsion-loquacious
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --main
81
+ - README.rdoc
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project: adhearsion-loquacious
98
+ rubygems_version: 1.8.10
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Descriptive configuration files for Ruby written in Ruby.
102
+ test_files: []