android-xml 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/lib/android-xml/defaults.rb +1 -1
- data/lib/android-xml/main.rb +7 -0
- data/lib/android-xml/version.rb +1 -1
- data/spec/android_resources_spec.rb +16 -0
- data/spec/generate_factory_spec.rb +30 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52c784cfcb74cb51e9004a25e2e632c24de7ecd
|
4
|
+
data.tar.gz: 38a5db410a520973a41116e2dadea6e1eb92909d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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') { '
|
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">
|
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.
|
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.
|
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
|
|
data/lib/android-xml/defaults.rb
CHANGED
data/lib/android-xml/main.rb
CHANGED
data/lib/android-xml/version.rb
CHANGED
@@ -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
|
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
|