android-xml 1.0.1 → 1.1.0

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: a0793c820b54e33008ab0e23d3dced7ca50d266a
4
- data.tar.gz: 8d338b708f0b94cce7185428059a6812c72db8c9
3
+ metadata.gz: a52c784cfcb74cb51e9004a25e2e632c24de7ecd
4
+ data.tar.gz: 38a5db410a520973a41116e2dadea6e1eb92909d
5
5
  SHA512:
6
- metadata.gz: 00d56612aa302e52dd46f737a0b3363a62012885c021aaa78d84384f33c389b26dee31dc436540364718e7ddaa72a78d71d7d4897cc101dbb98e7f5724f8dc01
7
- data.tar.gz: bd086cf1f762170d437b155ba95fe41f9b81eec20fe795cf8824006fc7efa159d7d088ad6c311e23e7a55ebb0bbb225f28fd17abf4c1af9f6925eec70ef910ae
6
+ metadata.gz: 72756c33d82683e8b3ef4ec2b490fae3eac82066a000a651525a83b1099fc67d91eaf88e26eab029a96a3e58db6323611f86140a121368941cd4bec01adb9571
7
+ data.tar.gz: d3dd641c1fecbdd3625de51e6e43bea79d9a01e7eac8378582f6d8d14feff0880656d0c81e405ab6496b0295352c9c4f06d2b27d8aa4d09d0e93641a4ccb358e
data/README.md CHANGED
@@ -11,7 +11,7 @@ require 'android-xml'
11
11
 
12
12
  AndroidXml.file('res/values/strings.xml') do
13
13
  resource do
14
- string(name: 'app_name') { 'AppityApp' }
14
+ string(name: 'app_name') { 'AppAppApp' }
15
15
  end
16
16
  end
17
17
 
@@ -25,7 +25,7 @@ AndroidXml.write_all
25
25
  <?xml version="1.0" encoding="utf-8"?>
26
26
  <!-- Do not edit this file. It was generated by AndroidXml -->
27
27
  <resources>
28
- <string name="app_name">AppityApp</string>
28
+ <string name="app_name">AppAppApp</string>
29
29
  </resources>
30
30
 
31
31
  # About
@@ -43,7 +43,7 @@ expect, but hopefully you get a good productivity boost.
43
43
  ```ruby
44
44
  # The dreaded AndroidManifest file!
45
45
  AndroidXml.file('AndroidManifest.xml') do
46
- manifest package: 'com.your_name_here.AppityApp', versionCode: 1, versionName: 1.0 do
46
+ manifest package: 'com.your_name_here.AppAppApp', versionCode: 1, versionName: 1.0 do
47
47
  uses_sdk minSdkVersion: 11
48
48
 
49
49
  application label: '@string/app_name', icon: '@drawable/ic_launcher' do
@@ -59,7 +59,7 @@ AndroidXml.file('AndroidManifest.xml') do
59
59
 
60
60
  activity name: 'DisplayMessageActivity',
61
61
  label: '@string/app_name',
62
- parentActivityName: 'com.your_name_here.AppityApp.MainActivity'
62
+ parentActivityName: 'com.your_name_here.AppAppApp.MainActivity'
63
63
  end
64
64
  end
65
65
  end
@@ -67,10 +67,15 @@ end
67
67
  # You can generate multiple files from one .rb file
68
68
  AndroidXml.file('res/values-jp/strings.xml') do
69
69
  resource do
70
- string(name: 'app_name') { 'アッピティアップ' }
70
+ string(name: 'app_name') { 'アッピアッピアッピ' }
71
71
  end
72
72
  end
73
73
 
74
+ # If you want, you can replace `file` with the root node name
75
+ AndroidXml.resource('res/values/strings.xml') do
76
+ string(name: 'app_name') { 'AppAppApp' }
77
+ end
78
+
74
79
  AndroidXml.write_all
75
80
  ```
76
81
 
@@ -22,7 +22,7 @@ module AndroidXml
22
22
  end
23
23
 
24
24
  # remove the 'android:' prefix
25
- tag :string, :style, :item do
25
+ tag :string, :style, :item, :color do
26
26
  rename :name
27
27
  end
28
28
  tag :style do
@@ -112,4 +112,11 @@ module AndroidXml
112
112
  tags[@context][:defaults].merge!(attrs)
113
113
  end
114
114
 
115
+ def method_missing(method_name, filename, &block)
116
+ xml_file = file(filename) do
117
+ send(method_name, &block)
118
+ end
119
+ xml_file
120
+ end
121
+
115
122
  end
@@ -1,3 +1,3 @@
1
1
  module AndroidXml
2
- Version = '1.0.1'
2
+ Version = '1.1.0'
3
3
  end
@@ -62,6 +62,22 @@ XML
62
62
  <string name="action_settings">Settings</string>
63
63
  <string name="title_activity_main">MainActivity</string>
64
64
  </resources>
65
+ XML
66
+ end
67
+
68
+ it 'should generate a sensible color.xml file' do
69
+ xml = AndroidXml.file('res/values/color.xml') do
70
+ resources do
71
+ color(name: 'foo') { '#f00' }
72
+ end
73
+ end
74
+
75
+ expect(xml.to_s).to eql <<-XML
76
+ <?xml version="1.0" encoding="utf-8"?>
77
+ <!-- Do not edit this file. It was generated by AndroidXml -->
78
+ <resources>
79
+ <color name="foo">#f00</color>
80
+ </resources>
65
81
  XML
66
82
  end
67
83
 
@@ -0,0 +1,30 @@
1
+ require 'android-xml'
2
+
3
+ describe AndroidXml do
4
+
5
+ before do
6
+ AndroidXml.reset
7
+ AndroidXml.setup_defaults
8
+ end
9
+
10
+ it 'should generate <menu>' do
11
+ xml = AndroidXml.menu('tmp/test.xml') do
12
+ item id: '@+id/action_search',
13
+ icon: '@drawable/ic_action_search',
14
+ title: '@string/action_search',
15
+ showAsAction: 'ifRoom'
16
+ end
17
+
18
+ expect(xml.to_s).to eql <<-XML
19
+ <?xml version="1.0" encoding="utf-8"?>
20
+ <!-- Do not edit this file. It was generated by AndroidXml -->
21
+ <menu xmlns:android="http://schemas.android.com/apk/res/android">
22
+ <item android:id="@+id/action_search"
23
+ android:icon="@drawable/ic_action_search"
24
+ android:title="@string/action_search"
25
+ android:showAsAction="ifRoom" />
26
+ </menu>
27
+ XML
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: android-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -44,6 +44,7 @@ files:
44
44
  - spec/android_manifest_spec.rb
45
45
  - spec/android_menu_spec.rb
46
46
  - spec/android_resources_spec.rb
47
+ - spec/generate_factory_spec.rb
47
48
  - spec/generate_spec.rb
48
49
  homepage: https://github.com/colinta/android-xml
49
50
  licenses:
@@ -73,4 +74,5 @@ test_files:
73
74
  - spec/android_manifest_spec.rb
74
75
  - spec/android_menu_spec.rb
75
76
  - spec/android_resources_spec.rb
77
+ - spec/generate_factory_spec.rb
76
78
  - spec/generate_spec.rb