Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ilpoldo/connie
base: 83a7e4569f
...
head fork: ilpoldo/connie
compare: b646f26fe1
  • 4 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
5 Gemfile
@@ -1,8 +1,7 @@
source "http://rubygems.org"
group :development do
- gem "rspec", "~> 2.3.0"
- gem "bundler", "~> 1.0.0"
+ gem "rspec"
gem "jeweler", "~> 1.5.2"
- gem "rcov", ">= 0"
+ gem "rcov"
end
View
2  VERSION
@@ -1 +1 @@
-0.1.0
+0.1.1
View
6 lib/connie.rb
@@ -4,6 +4,7 @@
module Connie
+
# class Railtie < Rails::Railtie
# config.tabelle = ActiveSupport::OrderedOptions.new
#
@@ -21,6 +22,11 @@ module Connie
# end
@dictionaries_paths = [File.expand_path('dictionaries',File.dirname(__FILE__))]
VERSION = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ def self.dictionaries_paths
+ @dictionaries_paths
+ end
+
end
# The shorthand method to use connie
View
2  lib/connie/connie.rb
@@ -24,7 +24,7 @@ def self.pick_a_line_from(file_path, line_no = false)
file.inject { |choice, line| rand < 1/file.lineno.to_f ? line.strip : choice }
else
line = line_no % (file.lineno - 1) # cycles around the file
- file.readlines[line_no-1].strip
+ file.readlines[line-1].strip
end
end
end
View
7 lib/connie/parser.rb
@@ -5,7 +5,7 @@ class Parser
attr_accessor :dictionary
@syntax = {# :method or :dictionary.method
- %r{((?:[\\]+)?\:[a-z]\w+(?:.\w+)?)} => lambda do |dictionary_and_method|
+ %r{((?:[\\])?\:[a-z]\w+(?:\.\w+)?)} => lambda do |dictionary_and_method|
arguments = dictionary_and_method[1..-1].split('.').map &:to_sym
case arguments.size
when 2 then Connie[arguments[0]].send arguments[1]
@@ -13,15 +13,14 @@ class Parser
end
end,
# :d - one digit
- %r{((?:[\\]+)?\:[wWd])(?:[^\w\{])} => lambda do |letter_or_digit|
+ %r{((?:[\\])?\:[wWd])(?:[^\w\{])} => lambda do |letter_or_digit|
Connie.formats letter_or_digit[1].to_sym
end,
# :w{2,4} - two to four letters
- %r{((?:[\\]+)?\:[wWd](?:\{\d+(?:,\d+)?\}))} => lambda do |character_and_frequency|
+ %r{((?:[\\])?\:[wWd](?:\{\d+(?:,\d+)?\}))} => lambda do |character_and_frequency|
character, f_min, f_max = character_and_frequency[1..-1].match(%r{(\w)(?:\{(\d+)(?:,(\d+))?\})})[1..-1]
Connie.formats character.to_sym, f_min.to_i, f_max.to_i
end
-
}
def self.process string_to_parse, dictionary = Connie[:names]
View
13 spec/connie_spec.rb
@@ -10,13 +10,16 @@
Connie(:'names.male').should eql('Mark')
end
- it "returns a dictionary using the shorthand" do
- Connie(:names).male.should eql('Mark')
+ it "returns a dictionary using the () shorthand" do
+ dictionary = Connie(:names)
+ dictionary.class.should eql(Connie::Dictionary)
+ dictionary.male.should eql('Mark')
end
it "returns a dictionary using []" do
- raise Connie[:names].inspect
- Connie[:names].male.should eql('Mark')
+ dictionary = Connie[:names]
+ dictionary.class.should eql(Connie::Dictionary)
+ dictionary.male.should eql('Mark')
end
it "parses a string passed" do
@@ -64,7 +67,7 @@ def where
module Address
def name_and_where
- interpolate ":names.first :names.last :geo.where"
+ interpolate ":names.male :names.last :geo.where"
end
end
end
View
1  spec/spec_helper.rb
@@ -7,6 +7,7 @@
require 'connie'
Connie.dictionaries_paths << File.expand_path('test_dictionaries', File.dirname(__FILE__))
+
Rspec.configure do |c|
c.mock_with :rspec
end
View
5 spec/test_dictionaries/numbers/ordinal
@@ -1,6 +1,3 @@
First
Second
-Third
-Fourth
-Fifth
-Sixth
+Third

No commit comments for this range

Something went wrong with that request. Please try again.