namazing 0.0.3 → 0.0.4

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: ee0f3661d5a46528c934aba1fc00a04bcdf35d26
4
- data.tar.gz: dd5287fd0d6580234eb685816d6a9e37050ee182
3
+ metadata.gz: 385c3380cce19f02a63bec889844e64ab5cfd29a
4
+ data.tar.gz: 877facb4a26ee0e4bda5c9634a14175d303e252f
5
5
  SHA512:
6
- metadata.gz: e7062a74916426f669b8162f665e2207972f11c517698e0bed2a548335cb18afbaab03c7135ca4519a608ee91053b7641e5bef6e6c5436f82942f7e6d651de16
7
- data.tar.gz: d823727aef71ef2796ebccb2bd913af71a112198d70f37804eeae31b74136baabf847bc8bf40f842c2c6c285e82b8df4446abfabdec3f5eb23b15bfa8174e2e4
6
+ metadata.gz: 9148f01204cca1a6b93654ebadc3f0125980aa9ecbd4f211176acb375c427768a75ec8c91e346d3d175507e1161656d39aa74be13382faa84f50e69d5dbfc823
7
+ data.tar.gz: 5ef5d67d5e42ae844d7c1b76ba5025f63e6de40974da3b78b7825634a61f211d1ac205195d4fae44bbfdf7e29f96cd5bd3e140fde2642ec918681e5227be4d1a
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1
data/README.md CHANGED
@@ -19,11 +19,11 @@ There are two main use cases for Namazing:
19
19
 
20
20
  1. Generating a random awesome word:
21
21
 
22
- Namazing.random
22
+ Namazing.random
23
23
 
24
24
  2. Making an existing word or string awesome:
25
25
 
26
- Namazing.to_awesome "boring_word"
26
+ Namazing.to_awesome "boring_word"
27
27
 
28
28
 
29
29
  ## Persistance
@@ -3,11 +3,11 @@ require_relative 'wordup'
3
3
 
4
4
  module Namazing
5
5
 
6
- WORDLIST = File.open(File.expand_path("../word_list_filtered.txt", __FILE__)).readlines.collect { |l| l.chomp! }
6
+ WORDLIST = File.open(File.expand_path('../word_list_filtered.txt', __FILE__)).readlines.collect { |l| l.chomp! }
7
7
  WORDLIST_SIZE = WORDLIST.size
8
8
 
9
9
  def self.version
10
- "0.0.3"
10
+ "0.0.4"
11
11
  end
12
12
 
13
13
  def self.random
@@ -25,8 +25,7 @@ module Namazing
25
25
 
26
26
  def self.convert boring_word
27
27
  digest = Digest::SHA256.hexdigest boring_word.downcase
28
- wordlist_line = (WORDLIST.size * digest[0..9].hex.to_f / ("F" * 10).hex).to_i
28
+ wordlist_line = (WORDLIST.size * digest[0..9].hex.to_f / ('F' * 10).hex).to_i
29
29
  WORDLIST[wordlist_line]
30
30
  end
31
-
32
- end
31
+ end
@@ -1,27 +1,22 @@
1
1
  require 'active_support/inflector'
2
2
 
3
3
  module Namazing
4
-
5
4
  class Wordup
6
5
 
7
6
  attr_accessor :boring, :awesomes
8
7
 
9
8
  def initialize boring
10
- @boring = boring
9
+ raise ArgumentError, 'Wordup requires a string' unless boring.class == String
10
+ @boring = boring.gsub(/ /, '_')
11
11
  @awesomes = []
12
- raise ArgumentError, "Wordup requires a string" if @boring.class.name != "String"
13
12
  end
14
13
 
15
14
  def split
16
- if type == :underscore
17
- return @boring.split("_")
18
- else
19
- return @boring.split /(?=[A-Z])/
20
- end
15
+ type == :underscore ? @boring.split('_') : @boring.split(/(?=[A-Z])/)
21
16
  end
22
17
 
23
18
  def awesome
24
- result = @awesomes.join("_")
19
+ result = @awesomes.join('_')
25
20
  if type == :camelcase
26
21
  return result.camelize(:lower)
27
22
  elsif type == :pascalcase
@@ -31,7 +26,7 @@ module Namazing
31
26
  end
32
27
 
33
28
  def word_count
34
- @boring.underscore.split("_").length
29
+ @boring.underscore.split('_').length
35
30
  end
36
31
 
37
32
  def type
@@ -46,7 +41,5 @@ module Namazing
46
41
  return :underscore
47
42
  end
48
43
  end
49
-
50
44
  end
51
-
52
- end
45
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Namazing do
4
-
5
4
  describe "#random" do
6
5
 
7
6
  subject { Namazing.random }
@@ -20,13 +19,11 @@ describe Namazing do
20
19
 
21
20
  it "should provide a random word" do
22
21
  srand(10)
23
- expect(subject).to eq("netminders")
22
+ expect(subject).to eq("prevocalic")
24
23
  end
25
-
26
24
  end
27
25
 
28
26
  describe "#convert" do
29
-
30
27
  subject { Namazing.convert "boring" }
31
28
 
32
29
  it "should be a string" do
@@ -50,11 +47,9 @@ describe Namazing do
50
47
  first = subject
51
48
  expect(Namazing.convert "slightlyboring").not_to eq (first)
52
49
  end
53
-
54
50
  end
55
51
 
56
52
  describe "#to_awesome" do
57
-
58
53
  subject { Namazing.to_awesome "boring" }
59
54
 
60
55
  it "should be a string" do
@@ -73,8 +68,5 @@ describe Namazing do
73
68
  first = subject
74
69
  expect(Namazing.to_awesome("Boring").downcase).to eq(first.downcase)
75
70
  end
76
-
77
-
78
71
  end
79
-
80
72
  end
@@ -1,21 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Namazing
4
-
5
4
  describe Wordup do
6
-
7
5
  describe "#initialize" do
8
-
9
6
  it "should require a string" do
10
7
  expect{Wordup.new(nil)}.to raise_error(ArgumentError)
11
8
  expect{Wordup.new(1)}.to raise_error(ArgumentError)
12
9
  expect{Wordup.new("boring")}.not_to raise_error
13
10
  end
14
-
15
11
  end
16
12
 
17
13
  describe "#word_count" do
18
-
19
14
  it "should return the correct number of words" do
20
15
  expect(Wordup.new("very_very_extremely_boring").word_count).to eq 4
21
16
  end
@@ -27,10 +22,13 @@ module Namazing
27
22
  it "should handle camelCase" do
28
23
  expect(Wordup.new("veryBoringName").word_count).to eq 3
29
24
  end
25
+
26
+ it 'should handle spaces' do
27
+ expect(Wordup.new("two words").word_count).to eq 2
28
+ end
30
29
  end
31
30
 
32
31
  describe "#type" do
33
-
34
32
  it "should identify underscore" do
35
33
  expect(Wordup.new("very_very_extremely_boring").type).to eq :underscore
36
34
  end
@@ -45,7 +43,6 @@ module Namazing
45
43
  end
46
44
 
47
45
  describe "#split" do
48
-
49
46
  it "should split underscore" do
50
47
  expect(Wordup.new("very_very_extremely_boring").split.length).to eq 4
51
48
  end
@@ -58,7 +55,5 @@ module Namazing
58
55
  expect(Wordup.new("veryBoringName").split.length).to eq 3
59
56
  end
60
57
  end
61
-
62
58
  end
63
-
64
- end
59
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,5 +4,4 @@ require 'rake'
4
4
  Dir[File.expand_path("../../lib/**/*.rb", __FILE__)].each { |f| require f }
5
5
 
6
6
  RSpec.configure do |config|
7
-
8
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namazing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Harper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport