home_assistant-generator 0.1.0.pre.alpha.pre.15 → 0.1.0.pre.alpha.pre.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 452b5f5dc4d24b34822fcb5491116af049310a8c
4
- data.tar.gz: cd716d2e04ce7b929e7b4311118bc5b59e572ba4
3
+ metadata.gz: c2eb391bd803fa114fd12d0a348aa7ffa0890d5e
4
+ data.tar.gz: 0e35575e164c6ea2159db9d2a3b10ff9dc0a73e7
5
5
  SHA512:
6
- metadata.gz: eaff0ae8bbed70d50fc532dd14655a9ec9206c9e14fc5946585d56043d77fc52541b46930f78c18731a8dfbffc12c2d9f569659e16741d8bca806f4654353bed
7
- data.tar.gz: fd4dda4cd6eb269069e011a71de7f948dd18098ad4ae7408ab1d9eeabd85ce2a47ee0d3fc7ceeae7d31d9c86b5ec1d9b0ef30cacf60e5dfe2dfe8e955222821e
6
+ metadata.gz: afe65f955631ad4f44e223c3f9b8f9b1cd09e81ce3867fbd292d37bebb706540015ab90d0a4e4ec3b4b87350213f3814cd66e1592620645f011f15b674b12bf1
7
+ data.tar.gz: b9e2903cf8154135b561d165e65fe9138549cb0ca3efb7012058da58bdf5993a53628a10a7556cc3473b642f30ae6511edc3f7e0825f7247c931b7f8d4a80aa7
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rspec', '~> 3.0'
24
24
 
25
25
  spec.add_runtime_dependency 'mash'
26
+ spec.add_runtime_dependency 'activesupport'
26
27
  end
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  require_relative 'component'
4
- require_relative 'switch'
4
+ require_relative 'plural'
5
5
  require_relative 'automation'
6
6
 
7
7
  module CamelCase
@@ -1,3 +1,5 @@
1
+ require 'active_support/inflector'
2
+
1
3
  module HomeAssistant
2
4
  module Generator
3
5
  # using default Component class behavior would lead to write:
@@ -23,18 +25,22 @@ module HomeAssistant
23
25
  # command_on '...'
24
26
  # command_off '...'
25
27
  # end
26
- class DSL
27
- class Switch < Component
28
- def name(value)
29
- @switch_name = value
30
- end
31
- def platform(value)
32
- @platform = value
33
- end
28
+ class PluralComponent < Component
29
+ def name(value)
30
+ @element_name = value
31
+ end
32
+
33
+ def platform(value)
34
+ @platform = value
35
+ end
34
36
 
35
- def to_h
36
- { 'platform' => @platform, 'switches' => { @switch_name => super } }
37
- end
37
+ def to_h
38
+ plural = self.class.name.downcase.split('::').last.pluralize
39
+ { 'platform' => @platform, plural => { @element_name => super } }
40
+ end
41
+ end
42
+ class DSL
43
+ class Switch < PluralComponent
38
44
  end
39
45
  end
40
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: home_assistant-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.pre.15
4
+ version: 0.1.0.pre.alpha.pre.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - grego_homeassistant@familleseux.net
@@ -89,8 +103,8 @@ files:
89
103
  - lib/home_assistant/generator/automation.rb
90
104
  - lib/home_assistant/generator/component.rb
91
105
  - lib/home_assistant/generator/dsl.rb
106
+ - lib/home_assistant/generator/plural.rb
92
107
  - lib/home_assistant/generator/properties.rb
93
- - lib/home_assistant/generator/switch.rb
94
108
  - lib/home_assistant/generator/version.rb
95
109
  homepage:
96
110
  licenses: